How to clear the pip cache and uv cache
pip and uv keep every downloaded and built wheel so the next install is fast. Big ML packages make these caches grow into many GB. Both tools have their own clear command, so you rarely need rm.
pip
python3 -m pip cache dir python3 -m pip cache info python3 -m pip cache purge # everything python3 -m pip cache remove "torch*" # matching wheels only
- macOS:
~/Library/Caches/pip - Linux:
~/.cache/pip - Windows:
%LOCALAPPDATA%\pip\Cache(usepy -m pip)
uv
uv cache dir uv cache size # recent uv versions uv cache prune # unused entries only: safe to run any time uv cache clean # everything uv cache clean numpy # one package
- macOS and Linux:
~/.cache/uv(or$XDG_CACHE_HOME/uv) - Windows:
%LOCALAPPDATA%\uv\cache
uv links files from its cache into virtual environments (clones on macOS, hard links on Linux and Windows), so clearing the cache may free less than its size while existing .venv folders still use those files.
Conda
conda clean --all --dry-run conda clean --all
Conda keeps its own package cache. Environments are separate and are not touched.
Measure with devdisk
devdisk is a free, read-only scanner. It lists both the pip and uv caches under Safe to regenerate with the matching purge or clean command. It never deletes anything; it only shows sizes and writes a cleanup script you read and run yourself.
curl -fsSLO https://disk.sadana.app/devdisk.py && python3 devdisk.py
iwr https://disk.sadana.app/devdisk.py -OutFile devdisk.py; py devdisk.py
Want one-click cleanup?
A planned devdisk desktop app for Mac and Windows: live treemap, cleanup that moves files to the Trash, scheduled scans. One email when it launches, with an early-supporter price. Your address is used only for that, and every email has an unsubscribe link.
FAQ
Will clearing the pip cache break my virtualenvs?
No. Installed packages live in the environment. Only future installs re-download.
uv cache prune or uv cache clean?
prune removes entries nothing uses and is safe to run regularly. clean empties the whole cache.
Does devdisk touch .venv folders?
No. It only reads sizes and never deletes anything.