Fix Python – How to free disk space taken up by (ana)conda?


Asked By – Make42

I am using the conda package manager – a lot. By now I have quite a few environments and a lot of downloaded packages taking a lot of space on my SSD. An obvious path to free some of that space is to use the command

conda env export > environment.yml

from to export which packages my old, inactive projects use(d) and then delete these environments. As far as I understand, this should free some of the space in anaconda2/envs/, but not in anaconda2/pkgs/. How do I get rid of these packages? Also, I suspect that there might be quite a few packages still sitting around, to which no environment is linking to – could that happen?


  1. In general: What is the best way to reduce the space taken up by conda?
  2. How do I get rid of packages that no environment is using anymore? How do I prune my packages? I am searching for something like sudo apt-get autoremove from Ubuntu/Debian.

Now we will see solution for issue: How to free disk space taken up by (ana)conda?


You can free some space with:

conda clean --all

clean Remove unused packages and caches.

Conda already use symlinks when possible for packages. So, not much to improve here, I guess.

Ok, thanks, but I would like to know “not for a specific environment, but in general” – for all environments.

You can list all packages in all envs with a few lines of Python:

import os
import subprocess
for env in os.listdir('/Users/me/miniconda3/envs'):['conda', 'list', '-n', env])

This question is answered By – Mike Müller

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0