user14094230
user14094230

Reputation: 502

If I remove a conda environment will it automatically remove all packages?

I would think it's obvious that it should uninstall all packages when removing an environment, since how would they be accessed otherwise, but I haven't seen documentation saying so, so I'm checking here if all packages need to be removed first.

Upvotes: 10

Views: 9264

Answers (2)

merv
merv

Reputation: 76750

Let's be more specific and remove the env foo located at anaconda3/envs/foo with

conda env remove -n foo

This usually deletes everything under anaconda3/envs/foo.

PyPI packages may stick around. If you previously used pip install in the environment, it can occasionally leave some residual things behind. If that's the case, you'll need to delete the anaconda3/envs/foo folder manually after conda env remove. Or you could try to pip uninstall any PyPI packages first1, to get a clean conda env remove result.

Conda also caches all packages, independent of whether or not they are currently in use. This would be under anaconda3/pkgs (usually). To additionally delete the packages no longer in use, one can use

conda clean -tp  # delete tarballs and unused packages

1: There is a command to programmatically remove all PyPI-installed packages from Conda environments in this answer.

Upvotes: 13

arckoor
arckoor

Reputation: 330

The conda environment will be deleted. Sometimes some packages stay behind, although they are not bound to any environment. You can delete these under <your anaconda folder> -> envs -> <the env you deleted>.

Upvotes: 1

Related Questions