user1687717 user1687717 - 2 months ago 58
Python Question

ImportError: No module named django.core.wsgi for uwsgi

I'm using uwsgi for my Django(version =1.4) project, but there's an error if I run

uwsgi --ini django.ini



from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi


but I could import django.core.wsgi as follows:

>>> import django.core.wsgi


the django.ini file:


[uwsgi]
chdir=/path/to/my/app
module=app.wsgi:application
master=True
vacuum=True
max-requests=5000
socket=127.0.0.1:9000


wsgi.py

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Answer

If you use virtualenv try to add home to django.ini:

home=/path/to/venv/

To test it through web browser:

uwsgi --ini django.ini --protocol=http
Comments