Conda keeps a package cache and a full copy per environment
Each environment can be gigabytes, and the package cache holds every tarball ever downloaded. What conda clean removes and what it does not.
Anaconda is large before you do anything with it, and each environment you create adds another copy of whatever it needs. A data science Mac with six environments is carrying six scientific stacks, and several of those environments were made for something that finished months ago.
Measure the two halves
conda info --envs
du -sh ~/anaconda3 ~/miniconda3 ~/.conda 2>/dev/null
du -sh ~/anaconda3/envs/* ~/miniconda3/envs/* 2>/dev/null | sort -hThe first line is the list that matters. Every environment there is a full directory tree, and one with a machine learning framework in it can be several gigabytes on its own.
What conda clean actually removes
| Command | Removes |
|---|---|
conda clean --tarballs | Downloaded package archives, kept after install |
conda clean --packages | Unused packages in the package cache |
conda clean --index-cache | The channel index |
conda clean --all | All of the above |
None of those touch your environments, which is the important thing to know: conda clean --all is safe and it does not remove anything you are using. It also, for the same reason, does not solve the problem if your environments are the large part.
Removing environments you no longer need
conda env remove --name old-project-envBefore removing one, export it so it can be recreated exactly. That turns a several gigabyte folder into a file of a few kilobytes, which is the trade you want for anything you might come back to:
conda env export --name old-project-env > old-project-env.ymlThe pip cache underneath
Conda environments usually contain pip installs as well, and pip keeps its own cache separately from conda's. It is a separate command and a separate folder, covered along with virtual environments in what Python leaves on a Mac.
Common questions
How much space does Anaconda use on a Mac?
The base installation alone is typically several gigabytes, and each environment you create adds its own copy of whatever packages it needs. A machine with several environments containing scientific or machine learning packages can easily reach tens of gigabytes.
Does conda clean delete my environments?
No. conda clean --all removes cached package archives, unused packages in the cache and the channel index. Environments are untouched, which also means it will not help if the environments themselves are what is large.
How do I remove a conda environment?
Run conda env remove --name followed by the environment name. Export it first with conda env export to a yml file, which recreates it exactly later and turns gigabytes into a few kilobytes.
Where does conda store its package cache?
Inside the installation directory, usually ~/anaconda3/pkgs or ~/miniconda3/pkgs, with configuration in ~/.conda. The cache holds downloaded archives kept after installation, which is what conda clean --tarballs removes.