gpt4 book ai didi

python - 环境变量没有设置

转载 作者:行者123 更新时间:2023-11-30 23:21:52 24 4
gpt4 key购买 nike

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

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

最佳答案

您需要导出环境变量:

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

关于python - 环境变量没有设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24763344/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com