3

I am getting an error "An error occurred importing your passenger_wsgi.py" on dreamhost server

passenger_wsgi.py file

import sys, os
INTERP  = '/home/dramira/books.everycrave.me/intra/bin/python'
sys.path.append('/home/dramira/books.everycrave.me/flipbook/')
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
sys.path.append(os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

exact error i am getting when compiling the passenger_wsgi.py is

Traceback (most recent call last):
  File "passenger_wsgi.py", line 7, in <module>
    import django.core.handlers.wsgi
ImportError: No module named django.core.handlers.wsgi

i checked compiling the passenger_wsgi.py file for other website its working fine on same server. I dont know what problem i am facing here. Please help me out.

1 Answers1

0

Your passenger_wsgi.py looks fairly similar to mine, also hosted on Dreamhost. Three differences that stand out to me:

  1. You're only adding the current directory os.getcwd() to sys.path. In mine, I add the current directory and the project directory: os.path.join(os.getcwd(), 'projectname')).
  2. Your DJANGO_SETTINGS_MODULE is only called 'settings'. I use a qualified module: 'projectname.settings'
  3. This may be a difference in Django versions — I'm on 1.7 — but at some point I had to move away from application = WSGIHandler().

My actual WSGI invocation is now:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Matt Cooper
  • 927
  • 9
  • 16