Python taking up disk space on your Mac? Clear pip cache, conda and venvs
When Python is taking up disk space on a Mac, it's rarely Python itself. It's the packages: pip, uv, conda and Poetry each keep their own download cache, every project has its own virtual environment, and pyenv keeps every Python version you ever installed.
The short answer: package caches are safe to clear with each tool's own command: pip3 cache purge, uv cache clean, conda clean --all and poetry cache clear PyPI --all. They download again when needed. Virtual environments and Python versions need a look first: remove the ones of projects you're done with, and old pyenv versions with pyenv uninstall.
Where does Python keep its caches on a Mac?
- pip:
~/Library/Caches/pip, or~/.cache/pipin some setups.pip3 cache dirprints the one yours uses. Every Python on the Mac shares it. - uv:
~/.cache/uv(uv cache dirprints it). - conda: the
pkgsfolder of your installation, such as~/miniconda3/pkgsor~/anaconda3/pkgs. Environments are in itsenvsfolder. - Poetry:
~/Library/Caches/pypoetry, with downloads incacheandartifactsand the project environments it creates invirtualenvs. - pyenv: one full Python per version in
~/.pyenv/versions. - Hugging Face: models downloaded by
transformersordiffusersgo to~/.cache/huggingface, often the biggest of all. See Where Ollama, LM Studio and Hugging Face store models on a Mac.
How do I clear the pip cache on a Mac?
pip3 cache info
pip3 cache purge
The first shows where the cache is and how big it is; the second empties it. To drop one package only, use pip3 cache remove <package>. Clearing it doesn't touch anything installed: it only means the next pip install downloads again.
How do I clean the uv, conda and Poetry caches?
- uv:
uv cache cleanempties the cache;uv cache pruneremoves only entries nothing uses any more. - conda:
conda clean --all --dry-runshows what would go, thenconda clean --allremoves downloaded tarballs, the index cache, logs and packages no environment uses. Packages your environments still use stay. - Poetry:
poetry cache listnames the caches, andpoetry cache clear PyPI --allempties the PyPI one.
How do I find all venv folders and their sizes?
Every virtual environment holds a pyvenv.cfg file, whatever the folder is called (.venv, venv, env). This lists them under your code folder with their sizes, biggest last:
find ~/Projects -maxdepth 5 -name pyvenv.cfg 2>/dev/null | while read -r f; do du -sh "$(dirname "$f")"; done | sort -h
Change ~/Projects to where your code lives. pyvenv.cfg also names the Python the environment was made with: if that Python is uninstalled, the environment stops working anyway.
Is it safe to delete a virtual environment?
For a finished project, yes. For one you still use, check first: a rebuilt environment only matches if every package is recorded with its version in requirements.txt, uv.lock or poetry.lock. Packages you installed by hand don't come back. To rebuild one:
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
With uv, uv sync does it; with Poetry, poetry install. Poetry's own environments are listed by poetry env list and removed with poetry env remove --all inside the project. conda environments are listed by conda env list and removed with conda remove --name <env> --all.
How do I remove old Python versions with pyenv?
pyenv versions
pyenv uninstall 3.10.14
The first lists what's installed, with a star next to the one in use. Keep the version you set as global and any a project names in its .python-version file. Environments made with pyenv-virtualenv live inside their Python version and are removed with it.