Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Gunicorn ImportError: No module named django.core.wsgi

I have created a Django application but now have plans to use some asynchronous (real-time) functionality in some areas of the site. After doing some research I think I should use gevent-socketio and therefore it is required I switch the application server to Gunicorn.

I have fallen at the first hurdle of deploying Gunicorn, I have installed with the command sudo apt-get install gunicorn and try to run my application with gunicorn project.wsgi:application but it fails and produces the following error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 473, in spawn_worker
    worker.init_process()
  File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 100, in init_process
    self.wsgi = self.app.wsgi()
  File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 115, in wsgi
    self.callable = self.load()
  File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 33, in load
    return util.import_app(self.app_uri)
  File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 362, in import_app
    __import__(module)
  File "/home/alex/django_projects/fantasymatchday_1/fantasymatchday_1/wsgi.py", line 13, in <module>
    from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
2014-11-20 17:31:45 [6605] [INFO] Worker exiting (pid: 6605)
2014-11-20 17:31:45 [6600] [INFO] Shutting down: Master
2014-11-20 17:31:45 [6600] [INFO] Reason: Worker failed to boot.

Can anybody give me a clue to what I need to do from here?

I am using python 3.4.0 and Django 1.6

like image 649
Matchday Avatar asked Nov 20 '14 19:11

Matchday


1 Answers

You have to install django and gunicorn in the same environment.
If you use virtualenv make sure you have both in the same virtual environment.

like image 59
enodari Avatar answered Oct 11 '22 13:10

enodari