如何使用另一个 .yml 文件更新预先存在的 conda 环境.这在处理具有多个需求文件的项目时非常有用,例如 base.yml、local.yml、production.yml
等.
How can a pre-existing conda environment be updated with another .yml file. This is extremely helpful when working on projects that have multiple requirement files, i.e. base.yml, local.yml, production.yml
, etc.
例如,下面是一个 base.yml
文件,其中包含 conda-forge、conda 和 pip 包:
For example, below is a base.yml
file has conda-forge, conda, and pip packages:
base.yml
name: myenv
channels:
- conda-forge
dependencies:
- django=1.10.5
- pip:
- django-crispy-forms==1.6.1
实际环境是通过以下方式创建的:conda env create -f base.yml
.
The actual environment is created with:
conda env create -f base.yml
.
稍后,需要将额外的包添加到 base.yml
.另一个文件,比如 local.yml
,需要导入这些更新.
Later on, additional packages need to be added to base.yml
. Another file, say local.yml
, needs to import those updates.
之前的尝试包括:
使用导入定义创建 local.yml
文件:
creating a local.yml
file with an import definition:
channels:
dependencies:
- pip:
- boto3==1.4.4
imports:
- requirements/base.
然后运行命令:conda install -f local.yml
.
这不起作用.有什么想法吗?
This does not work. Any thoughts?
尝试使用 conda 环境更新:
conda activate myenv
conda env update --file local.yml --prune
--prune
卸载从 local.yml
中删除的依赖项,如 这个答案来自@Blink.
--prune
uninstalls dependencies which were removed from local.yml
, as pointed out in this answer by @Blink.
或者不需要激活环境(感谢@NumesSanguis):
Or without the need to activate the environment (thanks @NumesSanguis):
conda env update --name myenv --file local.yml --prune
请参阅 更新环境 在 Conda 用户指南中.
See Updating an environment in Conda User Guide.
这篇关于如何使用 .yml 文件更新现有的 Conda 环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!