Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I rename a conda environment?

I have a conda environment named old_name, how can I change its name to new_name without breaking references?

like image 310
pkowalczyk Avatar asked Feb 14 '17 16:02

pkowalczyk


People also ask

Can I rename conda environment?

Renames an existing environment. This command renames a conda environment via its name (-n/--name) or its prefix (-p/--prefix). The base environment and the currently-active environment cannot be renamed.

Can I move conda environment to another directory?

conda environments can get pretty big, so if you're running low on hard disk space and have another drive mounted, you can easily move your environment to a directory on the other drive and create a symbolic link to the new location.


1 Answers

You can't.

One workaround is to create clone a new environment and then remove the original one.

First, remember to deactivate your current environment. You can do this with the commands:

  • deactivate on Windows or
  • source deactivate on macOS/Linux.

Then:

conda create --name new_name --clone old_name conda remove --name old_name --all # or its alias: `conda env remove --name old_name` 

Notice there are several drawbacks of this method:

  1. It redownloads packages (you can use --offline flag to disable it)
  2. Time consumed on copying environment's files
  3. Temporary double disk usage

There is an open issue requesting this feature.

like image 157
pkowalczyk Avatar answered Sep 19 '22 15:09

pkowalczyk