Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove multiple conda environments using one command line

Tags:

conda

anaconda

I know that the following command can be used to remove one specific anaconda environment:

$ conda env remove -n env_name 

But, is there any way I can specify multiple anaconda environment names in the above command line?

like image 712
sksoumik Avatar asked Nov 01 '25 12:11

sksoumik


1 Answers

According to the conda documentation, it doesn't seem like conda remove supports multiple envs, but a simple for loop would do the trick.

On Windows:

FOR %G in (env1 env2 env3) DO (conda remove -n %G --all --yes)

Note that if this is done from within a batch script, you might have to use %%G instead of %G

On Linux:

for env_name in env1 env2 env3; do conda remove -n $env_name --all --yes; done

Also note that the --yes option will remove the confirmation promt from conda remove, so be careful not to accidentally remove the wrong envs.

like image 141
ejorstad Avatar answered Nov 04 '25 05:11

ejorstad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!