且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何重命名 conda 环境?

更新时间:2023-02-16 19:42:20

你不能.

一种解决方法是 create 克隆一个新环境,然后 删除原来的那个.

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:

  • 停用(在 Windows 上)或
  • source deactivate 在 macOS/Linux 上.
  • deactivate on Windows or
  • 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`

注意这种方法有几个缺点:

Notice there are several drawbacks of this method:

  1. 它重新下载包(你可以使用 --offline 标志来禁用它)
  2. 复制环境文件所花费的时间
  3. 临时双盘使用

有一个开放的问题请求此功能.

There is an open issue requesting this feature.