New answer:
From Conda 4.14 you will be able to use just:
conda rename -n old_name new_name
Although, under the hood, conda rename
still uses [1][2] undermentioned combination of conda create
and conda remove
.
Use the -d
flag for dry-run (not destination, as of v22.11.0)
conda rename -n old_name -d new_name
Old answer:
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:
- It redownloads packages (you can use
--offline
flag to disable it)
- Time consumed on copying environment's files
- Temporary double disk usage
There is an open issue requesting this feature.
Assuming your conda-env is named cenv
, it is as simple as :
$ conda activate cenv # . ./cenv/bin/activate in case of virtualenv
(cenv)$ conda install ipykernel
(cenv)$ ipython kernel install --user --name=<any_name_for_kernel>
(cenv)$ conda deactivate
If you restart your jupyter notebook/lab you will be able to see the new kernel available. For newer versions of jupyter kernel will appear without restarting the instance. Just refresh by pressing F5.
PS: If you are using virtualenv etc. the above steps hold good.
Best Answer
As mentioned in the comments, conda support for jupyter notebooks is needed to switch kernels. Seems like this support is now available through conda itself (rather than relying on pip). http://docs.continuum.io/anaconda/user-guide/tasks/use-jupyter-notebook-extensions/
conda install nb_conda
which brings three other handy extensions in addition to Notebook Conda Kernels.