ImportError:工头启动时没有名为my_project.wsgi的模块错误

时间:2014-12-09 23:04:44

标签: django heroku

我正在尝试将我的项目推送到heroku,我正在遵循这些说明:

https://devcenter.heroku.com/articles/getting-started-with-django

我目前仍然坚持说foreman start

我收到此错误: - >完整错误http://dpaste.com/3Y213Y2

(boothie.0.1)MTVL1289dd026:HerokuBoothie bli1$ foreman start
14:59:05 web.1  | started with pid 58353
14:59:05 web.1  | [2014-12-09 14:59:05 -0800] [58353] [INFO] Starting gunicorn 19.1.1
14:59:05 web.1  | [2014-12-09 14:59:05 -0800] [58353] [INFO] Listening at: http://0.0.0.0:5000 (58353)
14:59:05 web.1  | [2014-12-09 14:59:05 -0800] [58353] [INFO] Using worker: sync
14:59:05 web.1  | [2014-12-09 14:59:05 -0800] [58356] [INFO] Booting worker with pid: 58356
14:59:05 web.1  | [2014-12-09 14:59:05 -0800] [58356] [ERROR] Exception in worker process:
14:59:05 web.1  | Traceback (most recent call last):
14:59:05 web.1  |   File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
14:59:05 web.1  |     worker.init_process()
14:59:05 web.1  |   File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/workers/base.py", line 114, in init_process
14:59:05 web.1  |     self.wsgi = self.app.wsgi()
14:59:05 web.1  |   File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/app/base.py", line 66, in wsgi
14:59:05 web.1  |     self.callable = self.load()
14:59:05 web.1  |   File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
14:59:05 web.1  |     return self.load_wsgiapp()
14:59:05 web.1  |   File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
14:59:05 web.1  |     return util.import_app(self.app_uri)
14:59:05 web.1  |   File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/util.py", line 356, in import_app
14:59:05 web.1  |     __import__(module)
14:59:05 web.1  | ImportError: No module named HerokuBoothie.wsgi

这是我的项目结构图。该项目位于名为HerokuBoothie的目录中。 enter image description here

资料:

web: gunicorn HerokuBoothie.wsgi --log-file -

2 个答案:

答案 0 :(得分:2)

我认为这是由您的项目结构引起的;如果您按照heroku教程进入错误点(foreman start部分),您的目录结构将如下所示:

hellodjango/
    manage.py
    Procfile
    hellodjango/
        __init__.py
        settings.py
        urls.py
        wsgi.py
    venv/
        bin/
        include/
        lib/

您可以看到您的结构有点不同,您的结构中还有一个HerokuBoothie目录。我认为重新构建项目(类似mv ~/Development/Django/HerokuBoothie/HerokuBoothie/* ~/Development/Django/HerokuBoothie并删除空的HerokuBoothie目录)会解决此问题,但如果在代码中使用绝对路径,则可能需要更改某些代码。

答案 1 :(得分:2)

您必须设置pythonpath,因为您的HerokuBoothie模块位于另一个文件夹中:

web: gunicorn HerokuBoothie.wsgi --pythonpath ../HerokuBoothie --log-file -