Skip to content
Advertisement

How to manually clean up conda in my home directory?

I use Anaconda in my computer to handle my python versions and environments. The location of the Anaconda installation (and consequently the default location for newly created environments) is /opt/anaconda3/. I have two custom environments that I have created – envA and envB. envA is present in /opt/anaconda3/envs/envA and envB is in ~/.conda/envs/envB. This is because I chose it that way — envB is for some personal experiments and research and hence it made sense to create it in my home directory.

Now, after some time, when the unused packages and caches occupied too much of my disk space, I ran a clean up by doing

conda clean --all

I observed that the above line cleaned up only the default directory at /opt/anaconda3, but not the one in my home directory. I have only one environment (envB) in my home directory and yet ~/.conda/envs/ occupies close to 6 GB of disk space so I am pretty sure conda clean had no effect on my home directory.

Hence, I have two specific questions:

  • Is there a way to make conda clean work on my home directory as well? I tried conda clean <dir> but that does not work.

  • If I were delete unused packages and the caches manually, which directories/files do I delete within ~/.conda? Here is a quick display of the directory structure.

    ~/.conda/
        -> environments.txt
        -> envs/
            -> envB/
            -> .pkgs/
        -> pkgs/
    

I figured I should delete the contents of either ~/.conda/pkgs or ~/.conda/envs/.pkgs, because they both occupy most of the space. From what I have seen, ~/.conda/envs/.pkgs/ contains several obviously unnecessary packages (incl multiple versions) and ~/.conda/pkgs/ seems to contain the essential packages for my environment. But here’s the catch — ~/.conda/pkgs contains only 27 package files, whereas envB has 43 packages in fact. So I think there may be some other packages in ~/.conda/envs/.pkgs that may be linked or referenced.

I have tried searching for the answer to this but could not find any answer, hence my decision to ask here as I am sure this would be helpful to many others too. Even the official conda documentation as well as github forum do not have any mention of this issue.

Thanks much for the help!

Advertisement

Answer

It turns out the .pkgs directory is the cache and may be safely deleted. An update to Conda also likely fixed this issue as the .pkgs/ directory in my system is now empty without me having performed any manual cleanup. Bulk of the space on the home directory is occupied by the <env>/lib/site-packages/ directory (for each environment), depending on which packages and libraries are installed. The pkgs/ directory on the top level holds additional packages.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement