Set environment variables in `environment.yml`

故事扮演 提交于 2019-12-22 03:48:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!