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
How can I rename a conda environment?
提问by pkowalczyk
I have a conda environment named old_name
, how can I change its name to new_name
without 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 deactivate
on Windows and source deactivate
on macOS/Linux)
(请记住deactivate
在 Windows 和source deactivate
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:
这种方法有几个缺点:
- it redownloads packages - you can use
--offline
flag to disable it, - time consumed on copying environment's files,
- temporary double disk usage.
- 它重新下载软件包 - 您可以使用
--offline
标志来禁用它, - 复制环境文件所消耗的时间,
- 临时双磁盘使用。
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_name
is better
conda create --name new_name --copy --clone old_name
更好
I use conda create --name new_name --clone old_name
which is without --copy
but 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 环境