ImportError:部署heroku应用程序时没有名为mysite.wsgi的模块消息

时间:2014-01-29 05:30:46

标签: heroku gunicorn django-wsgi

-Mac OSX 10.7.5 -Python 2.7 -PostgreSQL 9.3.2(通过Heroku设置)-Django 1.6

当我访问网站网址时,我收到“应用程序错误”消息。我有一个mysite / wsgi.py文件,这里有它的内容:

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
from dj_static import Cling

application = Cling(get_wsgi_application())

我的Procfile包含

web: gunicorn mysite.wsgi

当我跑“工头开始”时,我得到:

23:53:02 web.1  | started with pid 709
23:53:02 web.1  | /usr/local/foreman/bin/foreman-runner: line 41: exec: gunicorn: not found
23:53:02 web.1  | exited with code 127
23:53:02 system | sending SIGTERM to all processes
SIGTERM received

“Heroku logs”给了我:

logs
2014-01-28T11:08:04.245169+00:00 app[web.1]:     __import__(module)
2014-01-28T11:08:04.244817+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2014-01-28T11:08:04.245169+00:00 app[web.1]:     self.callable = self.load()
2014-01-28T11:08:04.245169+00:00 app[web.1]: ImportError: No module named mysite.wsgi
2014-01-28T11:08:04.459583+00:00 app[web.1]: 2014-01-28 11:08:04 [2] [INFO] Shutting down: Master
2014-01-28T11:08:04.459583+00:00 app[web.1]: 2014-01-28 11:08:04 [2] [INFO] Reason: Worker failed to boot.
2014-01-28T11:08:05.967655+00:00 heroku[web.1]: Process exited with status 3
2014-01-28T11:08:06.021577+00:00 heroku[web.1]: State changed from starting to crashed
2014-01-28T13:17:57.938033+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=nodemotion.herokuapp.com request_id=823e63b7-c67c-4d30-a610-3539d8996603 fwd="10.6.129.117, 199.204.164.130" dyno= connect= service= status=503 bytes=
2014-01-28T14:33:28.424579+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nodemotion.herokuapp.com request_id=be5be364-68d6-49cb-bdd8-47acc4dc7187 fwd="10.6.129.117, 199.204.164.130" dyno= connect= service= status=503 bytes=
2014-01-28T16:43:37.500012+00:00 heroku[web.1]: State changed from crashed to starting
2014-01-28T16:43:42.430719+00:00 heroku[web.1]: Starting process with command `gunicorn mysite.wsgi`
2014-01-28T16:43:43.781315+00:00 app[web.1]: 2014-01-28 16:43:43 [2] [INFO] Using worker: sync
2014-01-28T16:43:43.780648+00:00 app[web.1]: 2014-01-28 16:43:43 [2] [INFO] Starting gunicorn 18.0
201
4-01-28T16:43:43.781237+00:00 app[web.1]: 2014-01-28 16:43:43 [2] [INFO] Listening at: http://0.0.0.0:49328 (2)
2014-01-28T16:43:43.793707+00:00 app[web.1]: 2014-01-28 16:43:43 [7] [INFO] Booting worker with pid: 7
2014-01-28T16:43:43.798827+00:00 app[web.1]: 2014-01-28 16:43:43 [7] [ERROR] Exception in worker process:
2014-01-28T16:43:43.798827+00:00 app[web.1]: Traceback (most recent call last):
2014-01-28T16:43:43.798827+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
2014-01-28T16:43:43.799160+00:00 app[web.1]: 2014-01-28 16:43:43 [7] [INFO] Worker exiting (pid: 7)
2014-01-28T16:43:43.798827+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
2014-01-28T16:43:43.798827+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2014-01-28T16:43:43.798827+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
2014-01-28T16:43:43.799021+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2014-01-28T16:43:43.799021+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-01-28T16:43:43.798827+00:00 app[web.1]:     worker.init_process()
2014-01-28T16:43:43.798827+00:00 app[web.1]:     return self.load_wsgiapp()
2014-01-28T16:43:43.798827+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-01-28T16:43:43.798827+00:00 app[web.1]:     self.callable = self.load()
2014-01-28T16:43:43.799021+00:00 app[web.1]:     return util.import_app(self.app_uri)
2014-01-28T16:43:43.799021+00:00 app[web.1]:     __import__(module)
2014-01-28T16:43:43.799021+00:00 app[web.1]: ImportError: No module named mysite.wsgi
2014-01-28T16:43:43.799160+00:00 app[web.1]:     self.callable = self.load()
2014-01-28T16:43:43.799160+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
2014-01-28T16:43:43.799021+00:00 app[web.1]: Traceback (most recent call last):
2014-01-28T16:43:43.799021+00:00 app[web.1]:     worker.init_process()
2014-01-28T16:43:43.799021+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
2014-01-28T16:43:43.799021+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
2014-01-28T16:43:43.799021+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2014-01-28T16:43:43.799160+00:00 app[web.1]:     __import__

从“工头开始”结果,我收集说也许gunicorn没有正确安装,所以我下载了一个.gz并做了“sudo python setup.py install”和“import gunicorn”显示它安装得当。然后我再次做了“git push heroku”,但我仍然得到同样的错误。有没有人能够了解这里可能发生的事情?日Thnx。

1 个答案:

答案 0 :(得分:2)

问题是,我在我的app文件夹中添加了 init .py文件到.gitignore。因此,django没有将我的app文件夹识别为模块,因此导入错误。从.gitignore中删除 init .py文件解决了这个问题。