Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing Conda environment

I want to remove a certain environment created with conda. How can I achieve that? Let's say I have an active testenv environment. I tried, by following documentation, with:

$ conda env remove  CondaEnvironmentError: cannot remove current environment. deactivate and run conda remove again 

I then deactivate it:

$ source deactivate 

I try running again the command to remove it and I still get the same error. What is going wrong here?

like image 821
renatodamas Avatar asked Mar 06 '18 09:03

renatodamas


People also ask

Can I remove conda base environment?

It's not that, but instead that you can't remove the base environment, which is what the --all flag does. You can't uninstall all packages in base because that's where the conda executable lives. Instead, what you want to do is uninstall all user-installed packages.

How do I delete an environment?

Delete Environment Variables You need to just use the unset command with the variable name to delete it. This command will remove the variable permanently.


2 Answers

You probably didn't fully deactivate the Conda environment - remember, the command you need to use with Conda is conda deactivate (for older versions, use source deactivate). So it may be wise to start a new shell and activate the environment in that before you try. Then deactivate it.

You can use the command

conda env remove -n ENV_NAME 

to remove the environment with that name. (--name is equivalent to -n)

Note that you can also place environments anywhere you want using -p /path/to/env instead of -n ENV_NAME when both creating and deleting environments, if you choose. They don't have to live in your conda installation.

UPDATE, 30 Jan 2019: From Conda 4.6 onwards the conda activate command becomes the new official way to activate an environment across all platforms. The changes are described in this Anaconda blog post

like image 69
holdenweb Avatar answered Sep 22 '22 14:09

holdenweb


After making sure your environment is not active, type:

$ conda env remove --name ENVIRONMENT 
like image 25
renatodamas Avatar answered Sep 20 '22 14:09

renatodamas