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
?
Environment variables can be used in the following file types: Markdown and MDX. YAML, including portal configuration files. JavaScript and TypeScript, including the theme.
On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.
YAML does not natively support variable placeholders. Anchors and Aliases almost provide the desired functionality, but these do not work as variable placeholders that can be inserted into arbitrary regions throughout the YAML text. They must be placed as separate YAML nodes.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With