如何为要使用的气流设置环境变量?

时间:2017-07-07 22:37:28

标签: python environment-variables airflow apache-airflow

气流在尝试运行DAG时返回错误,说它无法找到环境变量,这很奇怪,因为它能够找到我存储的3个其他环境变量作为Python变量。这些变量根本没有问题。

我在~/.profile中拥有所有4个变量,并且还完成了

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

用户airflow运行的是什么?我也在export下完成了sudo个命令,因此我认为airflow在运行dag时会被products = ShopifyAPI::Product.find(123456789) products.images << ShopifyAPI::Image.new(:src=> "http://website/CF01.jpg", :position=> 1) products.save 选中

3 个答案:

答案 0 :(得分:1)

是否因为airflow使用非登录shell?您是否尝试将这些行放入:〜/ .bashrc而不是〜/ .profile?

答案 1 :(得分:0)

如果您仅运行本地实例,则应该能够像您期望的那样使用环境变量。请记住,您需要在运行Web服务器和调度程序的外壳程序中进行设置。如果它们在您的.profile中,则可能需要运行source ~/.profile

答案 2 :(得分:0)

根据 this answer,变量应该放在 /etc/default/airflow(在 Debian/Ubuntu 上)或 /etc/sysconfig/airflow(在 Centos/Redhat 上)。

相关问题