Last updated: Apr 11, 2024
Reading time·2 min

To rename a conda environment:
conda env list command if you need to get the name of the
environment.conda env list

conda deactivate

conda rename -n old_name new_name command to rename the
environment.The following example runs the command in with the --dry-run option to test
the expected behavior.
conda rename -n old_name --dry-run new_name
Once you're ready to run the real command, remove the --dry-run option.
conda rename -n old_name new_name
The conda rename command renames a conda environment via its name.
The -n (--name) option is used to specify the current name of the conda
environment.
When the -d (--dry-run) option is set, the command only displays what would
have happened if you had run it without the flag but it doesn't actually change
the environment's name.
Note that you can't rename the base environment.
conda environment by creating a new one and cloning itIf you use an older conda version ( < 4.14), you might have to rename the
environment in a couple of steps:
conda deactivate
Note that you can't rename a conda environment that is currently active.
conda create --name new_name --copy --clone old_name

conda env remove --name old_name
However, when using this approach, conda would have to re-download the
installed packages, so it is less performant than using conda rename.
There is no good reason to create a new environment and clone the old one if you
use conda version > 4.14 and can use conda rename.
You can learn more about the related topics by checking out the following tutorials: