oduleNotFoundError: 没有名为 'os.environ' 的模块



实际上我正在尝试在 heroku 中部署我的应用程序,鉴于我使用的是 python 3.6.3,我总是在 heroku 的日志中收到此异常

2017-10-09T22:14:05.288072+00:00 heroku[web.1]: State changed from crashed 
to starting
2017-10-09T22:14:07.772902+00:00 heroku[web.1]: Starting process with 
command `python BookmarkServer.py`
2017-10-09T22:14:10.065235+00:00 app[web.1]:     import os.environ
2017-10-09T22:14:10.065239+00:00 app[web.1]: ModuleNotFoundError: No module 
named 'os.environ'; 'os' is not a package
2017-10-09T22:14:10.064976+00:00 app[web.1]: Traceback (most recent call 
last):
2017-10-09T22:14:10.064990+00:00 app[web.1]:   File "BookmarkServer.py", 
line 47, in <module>
2017-10-09T22:14:10.158467+00:00 heroku[web.1]: Process exited with status 1
2017-10-09T22:14:10.179803+00:00 heroku[web.1]: State changed from starting 
to crashed

os.environ不是模块。它是os模块内部的可变environimport 语句仅导入模块。以这种方式使用它:

import os
print(os.environ)

其他用法:

from os import environ
print(environ)

我正在使用Heroku/Django并在推送过程中收到此错误。

我没有将django-environ添加到要求中,.txt。

我通过以下方式更新了文件:点冻结>要求.txt

Heroku随后下载了该模块。

最新更新