Python 为什么gunicorn看不到相应的环境变量?

Python 为什么gunicorn看不到相应的环境变量?,python,django,gunicorn,Python,Django,Gunicorn,在我的生产服务器上,我在virtualenv内部和外部都设置了环境变量(只是因为我不理解这个问题),包括一个变量HELLO\u WORLD\u PROD,我将其设置为'1'。在python解释器中,无论是在我的venv内部还是外部,os.environ.get('HELLO\u WORLD\u PROD')==“1”返回True。在我的设置文件夹中,我有: import os if os.environ.get('HELLO_WORLD_PROD') == '1': from hell

在我的生产服务器上,我在virtualenv内部和外部都设置了环境变量(只是因为我不理解这个问题),包括一个变量
HELLO\u WORLD\u PROD
,我将其设置为
'1'
。在python解释器中,无论是在我的venv内部还是外部,
os.environ.get('HELLO\u WORLD\u PROD')==“1”
返回
True
。在我的设置文件夹中,我有:

import os

if os.environ.get('HELLO_WORLD_PROD') == '1':
    from hello_world.settings.prod import *  # noqa
else:
    from hello_world.settings.dev import *  # noqa
prod.py和dev.py都继承自base.py,并且在base
DEBUG=False
中,只有在dev.py中才继承
DEBUG=True

但是,当我通过浏览器触发错误时,我看到的是调试页面

我用的是nginx和gunicorn。为什么我的应用程序导入了错误的设置文件

你可以看到我的枪角


提前感谢您的耐心等待

我正在使用sudo服务gunicorn start运行gunicorn。为了解决这个问题,我在gunicorn.conf的
exec
行中添加了使用标志的环境变量,比如
exec env/bin/gunicorn--env HELLO\u WORLD\u PROD=1--env DB\u PASSWORD=secret
等。

如何设置它们?