convoluted

Completely Remove a Conda Environment

by Rito Ghosh

When you are done with a project, (or choose to abandon it 😉), you might remove your conda environment. Like so:

conda remove --name ENV_NAME --all

Where ENV_NAME is the name of the environment.

If you are not sure, you can find the environments in your machine by:

conda env list

And, also make sure to deactivate the environment you are going to remove, if you are in it.

So, three steps:

  1. Deactivate the environment, if you have it activated.
  2. To copy the name proper, list all the environments, and copy the name.
  3. Remove the environment using conda.

But, even after you remove an environment, huge bloat remains. Especially if you are working in Deep Learning, where libraries and packages tend to be huge.

screengrab showing 59 GB of storage space

You can remove the bloat if you choose it.


For that you have to use the conda clean command.

After you have removed one or more environments, just run:

conda clean -a

Then just keep saying y 😬.

This is how you can remove the caches, and clean a conda environment fully, and save a ton of valuable space.

My results a while back:

saving 32 GB using conda clean

I was able to save ~33 GB of storage space by using this.


References:

  1. https://www.freecodecamp.org/news/how-to-delete-an-environment-in-conda/
  2. https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
  3. https://conda.io/projects/conda/en/latest/commands/remove.html

#guide #linux #note #python #tutorial