在 `environment.yml` 中设置环境变量

Set environment variables in `environment.yml`

我可以在 conda 环境中的 environment.yml 文件中设置环境变量吗?

Conda 让我通过 env_vars.sh 脚本 save environment variables in environments,但是有没有办法自动执行在 activate.d、[=15] 中创建 env_vars.sh 文件的过程=] 目录,根据 environment.yml 内的某些环境变量规范,用于可重现的环境,例如 MKL_THREADING_LAYER=GNU?

看起来这是在 Conda v4.9!

中添加的

https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#setting-environment-variables

处有文档

Environment variables set using conda env config vars will be retained in the output of conda env export. Further, you can declare environment variables in the environment.yml file as shown here:

name: env-name
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.7
  - codecov
variables:
  VAR1: valueA
  VAR2: valueB

旧版本的 conda 会报错;

EnvironmentSectionNotValid: The following section on 'environment.yml' is invalid and will be ignored:
 - variables