Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用travis ci中的django environ访问.env变量?_Python_Python 3.x_Django_Environment Variables_Travis Ci - Fatal编程技术网

Python 如何使用travis ci中的django environ访问.env变量?

Python 如何使用travis ci中的django environ访问.env变量?,python,python-3.x,django,environment-variables,travis-ci,Python,Python 3.x,Django,Environment Variables,Travis Ci,我正在尝试使用将travis ci与django项目集成,但在travis ci构建中不断出现相同的错误: UserWarning: Error reading /home/travis/.../.env - if you're not configuring your environment separately, check this. django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment v

我正在尝试使用将travis ci与django项目集成,但在travis ci构建中不断出现相同的错误:

UserWarning: Error reading /home/travis/.../.env - if you're not configuring your environment separately, check this.

django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment variable
看起来django环境找不到环境变量

我已经尝试通过.travis.yml文件导出
SECRET\u KEY
变量,如下所示: . 但似乎仍然不起作用

这是我的.env文件:

和部分my settings.py:

我还尝试在travis ci项目配置页面中设置变量


编辑:我发现一个有问题的解决方案: 由于正在设置变量,但由于某种原因,.env文件没有被创建(或者django环境没有找到变量),我手动创建了该文件,并将其设置为获取先前添加的变量

我是在.travis.yml文件的
before_脚本中执行此操作的:

我知道这不是解决问题的最好办法,但它正在发挥作用,我没有找到其他办法来解决它。我希望这能帮助同样有这个问题的人:)