I have a conda environment named old_name
, how can I change its name to new_name
without breaking references?
You can't.
One workaround is to create clone environment, and then remove original one:
(remember about deactivating current environment with deactivate
on Windows and source deactivate
on macOS/Linux)
conda create --name new_name --clone old_name
conda remove --name old_name --all # or its alias: `conda env remove --name old_name`
There are several drawbacks of this method:
--offline
flag to disable it,There is an open issue requesting this feature.
booooo why can't one rename a conda env?
so as to leave some work for those who fork conda and thereby making them understand much more en route :P :D
Another way is to clone the environment
conda create --name new_name --clone old_name
then you can remove the old one.Word of warning - I tried doing this, and ran into bizarre errors - my
.bashrc
no longer worked, and trying to runpytest
would fail, trying to reference the now-removed environment. I tried new shells and restarting with no luck. Ended up having to blow away the new environment, then just start with a clean install. Slower, but seems to actually work now.@dwanderson +5000 as I was going to try using this answer but instead I'm just going to pull the bandaid right off and recreate my badly named env from scratch.