Python 如何重命名 conda 环境?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42231764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 21:27:02  来源:igfitidea点击:

How can I rename a conda environment?

pythonanacondaconda

提问by pkowalczyk

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

我有一个名为 的 conda 环境old_name,如何在new_name不破坏引用的情况下更改其名称?

回答by pkowalczyk

You can't.

你不能。

One workaround is to createclone environment, and then removeoriginal one:

一种解决方法是创建克隆环境,然后删除原始环境:

(remember about deactivating current environment with deactivateon Windows and source deactivateon macOS/Linux)

(请记住deactivate在 Windows 和source deactivatemacOS/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:

这种方法有几个缺点:

  1. it redownloads packages - you can use --offlineflag to disable it,
  2. time consumed on copying environment's files,
  3. temporary double disk usage.
  1. 它重新下载软件包 - 您可以使用--offline标志来禁用它,
  2. 复制环境文件所消耗的时间,
  3. 临时双磁盘使用。

There is an open issuerequesting this feature.

有一个请求此功能的未决问题

回答by bgoodr

Based upon dwanderson's helpful comment, I was able to do this in a Bash one-liner:

根据dwanderson的有用评论,我能够在 Bash one-liner 中做到这一点:

conda create --name envpython2 --file <(conda list -n env1 -e )

My badly named env was "env1" and the new one I wish to clone from it is "envpython2".

我命名不当的 env 是“env1”,而我希望从中克隆的新 env 是“envpython2”。

回答by kkuma7

conda create --name new_name --copy --clone old_nameis better

conda create --name new_name --copy --clone old_name更好

I use conda create --name new_name --clone old_namewhich is without --copybut encountered pip breaks...

我使用的conda create --name new_name --clone old_name是没有--copy但遇到点子中断的...

the following url may help Installing tensorflow in cloned conda environment breaks conda environment it was cloned from

以下 url 可能有助于 在克隆的 conda 环境中安装 tensorflow 会破坏从其克隆的 conda 环境

回答by mengLV LI

Just open the folder"\Anaconda\envs" and rename it.

只需打开文件夹“\Anaconda\envs”并重命名即可。

Before Renamebefore rename

重命名前重命名前

After Renameafter rename

重命名后重命名后