[Django]-Django and Apache Issue

5👍

✅

It looks like you’re using a virtualenv – you need to activate that within your WSGI script to set up the paths correctly.

activate_this = os.path.join("path/to/my/virtualenv", "bin/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))

1👍

I’m guessing that apache is using either a different version of python or is using a different sys.path. What do you get as output for the sys.path?

1👍

Where is Django installed? From command line Python do:

import django
print django.__file__

If it isn’t installed in appropriate directory on sys.path under /usr/lib/python2.6 or /usr/local/lib/python2.6, then that is the problem.

Presuming you actually installed Django, this may occur because you have multiple installed Python versions and you used different one to what mod_wsgi is using to install Django. Or you used a virtual environment and haven’t told mod_wsgi where that is. Or you managed to install Django with permissions that Apache cannot read.

Go watch the video of talk and read through slides referenced at:

http://blog.dscpl.com.au/2010/06/sydney-pycon-modwsgi-talk-slides.html

They cover this sort of issue as well as a lot of other stuff related to permissions etc.

Leave a comment