问题
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?
回答1:
Current Status (Conda v4.7.12)
No, it is not possible to set env-specific environment variables in an env YAML.
Outlook: Perhaps in Conda v4.8
As @Ben pointed out in comments, this has been an open feature request. While it technically doesn't have a milestone set, a pull request referencing this issue was merged as part of milestone Conda v4.8.0 that looks like it provides some infrastructure for env-specific environment variables (i.e., without manually writing activation hooks). For example, the PR adds a conda-env command vars that can be used like
conda env vars set MKL_THREADING_LAYER=GNU
However, I could find neither code for parsing vars from a YAML nor new code for exporting vars to a YAML (but, admittedly, I only skimmed through it - mainly looking at the tests that were added).
In summary, the final answer is still not yet, but it could be on the horizon.
来源:https://stackoverflow.com/questions/47710371/set-environment-variables-in-environment-yml