How to update an existing Conda environment with a .yml file(如何使用 .yml 文件更新现有的 Conda 环境)
问题描述
如何使用另一个 .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 环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 .yml 文件更新现有的 Conda 环境
基础教程推荐
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
