How do I set an environment variable for airflow to use?

白昼怎懂夜的黑 提交于 2019-12-10 17:05:49

问题


Airflow is returning an error when trying to run a DAG saying that it can't find an environment variable, which is odd because it's able to find 3 other environment variables that I'm storing as a Python variable. No issues with those variables at all.

I have all 4 variables in ~/.profile and have also done

export var1="varirable1"
export var2="varirable2"
export var3="varirable3"
export var4="varirable4"

Under what user does airflow run? I've done those export commands under sudo as well, so I thought they would be picked up by airflow when it runs the dag


回答1:


Is it maybe because airflow uses non-login shell? Have you tried putting these lines in : ~/.bashrc instead of ~/.profile ?




回答2:


If you are just running a local instance you should be able to use environment variables like you expect. Remember that you need to set them in the shell that is running the webserver and scheduler though. If these are in your .profile, you may need to run source ~/.profile.



来源:https://stackoverflow.com/questions/44980616/how-do-i-set-an-environment-variable-for-airflow-to-use

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