如何使用.yml文件更新现有的Conda环境 [英] How to update an existing Conda environment with a .yml file

查看:508
本文介绍了如何使用.yml文件更新现有的Conda环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用另一个.yml文件更新先前存在的conda环境.当处理具有多个需求文件(即base.yml, local.yml, production.yml等)的项目时,这非常有用.

例如,下面是一个base.yml文件,其中包含conda-forge,conda和pip软件包:

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.

稍后,需要将其他软件包添加到base.yml.另一个文件,例如local.yml,需要导入这些更新.

先前完成此操作的尝试包括:

创建具有导入定义的local.yml文件:

channels:

dependencies:
  - pip:
    - boto3==1.4.4
imports:
  - requirements/base. 

然后运行命令: conda install -f local.yml.

这不起作用.有什么想法吗?

解决方案

尝试使用 conda env更新:

conda activate myenv
conda env update --file local.yml

或者无需激活环境(感谢@NumesSanguis):

conda env update --name myenv --file local.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.

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

The actual environment is created with: conda env create -f base.yml.

Later on, additional packages need to be added to base.yml. Another file, say local.yml, needs to import those updates.

Previous attempts to accomplish this include:

creating a local.yml file with an import definition:

channels:

dependencies:
  - pip:
    - boto3==1.4.4
imports:
  - requirements/base. 

And then run the command: conda install -f local.yml.

This does not work. Any thoughts?

解决方案

Try using conda env update:

conda activate myenv
conda env update --file local.yml

Or without the need to activate the environment (thanks @NumesSanguis):

conda env update --name myenv --file local.yml

这篇关于如何使用.yml文件更新现有的Conda环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆