問題描述
I'd like the root environment of conda to copy all of the packages in another environment. How can this be done?
There are options to copy dependency names/urls/versions to files.
Recommendation
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:
Options
Option 1 - YAML file
Within the second environment (e.g. myenv
), export names+ to a yaml file:
then update the first environment+ (e.g. root
) with the yaml file:
Option 2 - Cloning an environment
Use the --clone
flag to clone environments (see @DevC's post):
This basically creates a direct copy of an environment.
Option 3 - Spec file
Make a spec-file++ to append dependencies from an env (see @Ormetrom):
Alternatively, replicate a new environment (recommended):
See Also
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). Newer versions of conda can useconda activate
(this may require some setup with your shell configuration viaconda init
). - Discussion on keeping
conda env
Extras
There appears to be an undocumented conda run
option to help execute commands in specific environments.
The latter command is effective at running commands in environments without the activation/deactivation steps. See the equivalent command below:
Note, this is likely an experimental feature, so this may not be appropriate in production until official adoption into the public API.
+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環境進入root環境?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!