未设置环境变量

时间:2014-07-15 16:22:37

标签: python flask embedded environment-variables embedded-linux

我使用环境变量来传递设置文件:

app.config.from_envvar('DVR_SETTINGS')

它在我的开发系统上工作正常但是当我尝试在嵌入式Linux系统(arago)上部署这个东西时,我得到了这个:

RuntimeError: The environment variable 'DVR_SETTINGS' is not set and as such configuration could not be loaded.
Set this variable and make it point to a configuration file

但我已经做到了:

root@dm365-evm:/var/www/dvr# echo $DVR_SETTINGS
/var/www/dvr/settings/production.py

2 个答案:

答案 0 :(得分:3)

您需要导出环境变量:

export DVR_SETTINGS

您可以将设置和导出组合在一行中:

export DVR_SETTINGS=/var/www/dvr/settings/production.py

或者你可以将它放在运行Flask服务器的行上:

DVR_SETTINGS=/var/www/dvr/settings/production.py python flask_script.py

答案 1 :(得分:0)

在OS窗口中,您需要导出环境变量:

  • 打印(os.environ)您可以看到所有环境的列表
  • 设置“环境变量”