在 `environment.yml` 中设置环境变量 [英] Set environment variables in `environment.yml`
问题描述
我可以在 condaenvironment.yml 文件中设置环境变量吗> 环境?
Can I set environment variables in environment.yml
files in conda environments?
Conda 让我 在环境中保存环境变量 通过 env_vars.sh
脚本,但是有没有办法自动化在 activate.d
中创建 env_vars.sh
文件的过程code>, deactivate.d
目录根据 environment.yml
中的一些环境变量规范,用于可重现的环境,例如 MKL_THREADING_LAYER=GNU
?
Conda lets me save environment variables in environments via the env_vars.sh
script, but is there a way to automate the process of creating env_vars.sh
files in the activate.d
, deactivate.d
directories according to some specification of environment variables within environment.yml
, for a reproducible environment with, say, MKL_THREADING_LAYER=GNU
?
推荐答案
好像是在Conda v4.9中添加的!
It looks like this was added in Conda v4.9!
使用 conda env config vars
设置的环境变量将保留在 conda env export
的输出中.此外,您可以在 environment.yml
文件中声明环境变量,如下所示:
Environment variables set using
conda env config vars
will be retained in the output ofconda env export
. Further, you can declare environment variables in theenvironment.yml
file as shown here:
name: env-name
channels:
- conda-forge
- defaults
dependencies:
- python=3.7
- codecov
variables:
VAR1: valueA
VAR2: valueB
旧版本的 conda 会报错;
Older versions of conda will complain;
EnvironmentSectionNotValid: The following section on 'environment.yml' is invalid and will be ignored:
- variables
这篇关于在 `environment.yml` 中设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!