Search code examples
pythondjangopassengerdreamhost

passenger_wsgi.py not working properly with django


I am hosting my Django application on Dreamhost. Dreamhost serves Django-1.2.1 on Python-2.5.2, but I use Django-1.3.1 on Python-2.7.2, for my app.
before making any changes to meet my requirements, the passenger_wsgi.py contained the following:

import sys, os
sys.path.append(os.getcwd())
sys.path.insert(1, '/home/username/example.com/projects')
os.environ['DJANGO_SETTINGS_MODULE'] = "projectname.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

the app runs but with some missing modules because of the old version of Django.

So I installed python-2.7.2 on /home/username/opt/Python-2.7.2, and then installed Django-1.3.1 on it using pip tool.

and made some changes to passenger_wsgi.py to make the app run on python-2.7.2. and became like this:

import sys, os

# makes sure the interpreter executable is python2.7
INTERP = os.path.join(os.environ['HOME'], 'opt', 'Python-2.7.2', 'bin', 'python2.7')
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)

sys.path.append(os.getcwd())
sys.path.insert(1, '/home/username/example.com/projects')
os.environ['DJANGO_SETTINGS_MODULE'] = "projectname.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

when I try to run the code again, the following error rises

An error occurred importing your passenger_wsgi.py

can anyone help??


Solution

  • I figured out the problem. I just hadn't installed mysql-python module, that caused the project to crash on running when it reaches the part related to database configuration in the setting.py file