We can use
conda env config vars set MY_VAR=something
or in an environment.yml
block
variables:
MY_VAR: something
MY_VAR2: ${CONDA_PREFIX}/abc
to define variables for the conda environment.
The set variables become available when we do conda activate <env>
and are unset on con deactivate
.
See e.g.
- https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#setting-environment-variables
- How to set specific environment variables when activating conda environment?
I would expect the definitions to be in
<env location>/etc/conda/[de]activate.d
but the are not, even though after conda activate <env>
they are shown when I do
conda env config vars list
This gives something like
MY_VAR = something
MY_VAR2 = ${CONDA_PREFIX}/abc
With $CONDA_PREFIX
not being expanded.
When I do
conda env config vars set MY_VAR2=${CONDA_PREFIX}/abc
conda deactivate
conda activate <env>
it works as expected and $CONDA_PREFIX
is expanded.
So,
- Where are the variables defined, i.e. set / unset?
- Why is
$CONDA_PREFIX
not expanded when used in theenvironment.yml
? - How to set variables using environment variables via
environment.yml
?