Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named my_project.wsgi error with foreman start

Tags:

django

heroku

I am trying to push my project into heroku and I am following these instructions:

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

I am currently stuck on the part the says foreman start

I get this error: --> full error 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

Here is a picture of my project structure. The project is located inside a directory called HerokuBoothie. enter image description here

Profile:

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

like image 877
Liondancer Avatar asked Dec 09 '14 23:12

Liondancer


2 Answers

I think it's caused by your project structure; if you follow the heroku tutorial onto the point you have error (foreman start part), your directory structure would look like this:

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

You can see the structure you have is a bit different, there's an additional HerokuBoothie directory in your structure. I think restructure your project (something like mv ~/Development/Django/HerokuBoothie/HerokuBoothie/* ~/Development/Django/HerokuBoothie and remove the empty HerokuBoothie dir) would solve this issue, but you might have to change some codes if you use absolute paths in your codes.

like image 192
dazedconfused Avatar answered Oct 25 '22 02:10

dazedconfused


You have to set the pythonpath as your HerokuBoothie module is located in another folder:

web: gunicorn HerokuBoothie.wsgi --pythonpath ../HerokuBoothie --log-file -
like image 31
Reto Aebersold Avatar answered Oct 25 '22 01:10

Reto Aebersold