Reputation: 2253
Can I set environment variables in environment.yml
files in conda environments?
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
?
Upvotes: 31
Views: 11355
Reputation: 418
It looks like this was added in Conda v4.9!
There is documentation at 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 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
Older versions of conda will complain;
EnvironmentSectionNotValid: The following section on 'environment.yml' is invalid and will be ignored:
- variables
Upvotes: 26