问题描述
我希望conda的根环境在另一个环境中复制所有软件包.如何才能做到这一点?
I'd like the root environment of conda to copy all of the packages in another environment. How can this be done?
推荐答案
有一些选项可以将依赖项名称/URL/版本复制到文件中.
There are options to copy dependency names/urls/versions to files.
推荐
通常,在新环境中工作比更改root
更安全.但是,在尝试更改之前,请考虑备份现有环境.通过在演示环境中测试这些命令来验证所需的结果.例如,要备份您的root
env:
Normally it is safer to work from a new environment rather than changing root
. However, consider backing up your existing environments before attempting changes. Verify the desired outcome by testing these commands in a demo environment. To backup your root
env for example:
λ conda activate root
λ conda env export > environment_root.yml
λ conda list --explicit > spec_file_root.txt
选项
选项1 -YAML文件
在第二个环境(例如myenv
)中,将名称 导出到yaml文件:
Within the second environment (e.g. myenv
), export names to a yaml file:
λ activate myenv
λ conda env export > environment.yml
然后更新带有Yaml文件的第一个环境 (例如root
):
λ conda env update --name root --file environment.yml
选项2 -克隆环境
Option 2 - Cloning an environment
使用 --clone
标志以克隆环境(请参见@DevC的帖子):
Use the --clone
flag to clone environments (see @DevC's post):
λ conda create --name myclone --clone root
这基本上创建了环境的直接副本.
This basically creates a direct copy of an environment.
选项3 -规范文件
制作规范文件 ,用于附加来自环境的依赖项(请参阅@Ormetrom):
Make a spec-file to append dependencies from an env (see @Ormetrom):
λ activate myenv
λ conda list --explicit > spec_file.txt
λ conda install --name root --file spec_file.txt
或者,复制一个新环境(推荐):
Alternatively, replicate a new environment (recommended):
λ conda create --name myenv2 --file spec_file.txt
另请参见
-
conda env
了解有关env子项的更多详细信息命令. - Anaconada Navigator 桌面程序,以获得更多图形体验.
- 文档有关更新的命令.对于较旧的conda版本,请使用
activate
(Windows)和source activate
(Linux/Mac OS). - 讨论关于保持
conda env
conda env
for more details on the env sub-commands.- Anaconada Navigator desktop program for a more graphical experience.
- Docs on updated commands. With older conda versions use
activate
(Windows) andsource activate
(Linux/Mac OS). - Discussion on keeping
conda env
Conda文档已更改;链接已更新. 规范文件仅适用于在同一OS上创建的环境.与前两个选项不同,spec文件仅捕获指向conda依赖项的链接.不包括点子依存关系.
Conda docs have changed since the original post; links updated.Spec-files only work with environments created on the same OS. Unlike the first two options, spec-files only capture links to conda dependencies; pip dependencies are not included.
这篇关于您如何“克隆"到您的计算机?将conda环境转换为根环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!