views:

118

answers:

1

I have a Django project that works fine with the development server that comes with it.

No errors are produced at all when I use "django manage.py runserver" and the app works fine, but when I try to use it with mod_wsgi and Apache the browser displays "Internal Server Error" with a 500 error code and it generates an import error in the Apache error log.

Here's the error in the log:

ImportError: No module named registration

I'm using the Django registration module which is located in a path like this:

/opt/raj/photos/registration

I know that the registration app is in the path because I can fire up a Python shell, import sys, and get a list of paths using sys.path.

Here are some of the paths output from Python shell:

sys.path ['', '/opt/raj/pyamf', '/opt/raj', '/opt/raj/pictures', '/opt/raj/pictures /registration', '/usr/lib/python2.6',....]

Any thoughts would be appreciated.

+2  A: 

Is it in the pythonpath for the webserver? All those '/opt' paths are typically not in the standard python path, so something is adding those for you I would guess. Are you sure it also gets added for the webserver process, or is PYTHONPATH set in some shell configfile somewhere for your user only?

There is a PythonPath directive when using mod_python, is there something similar for mod_wsgi?

This is almost certainly a case of the path not being the same for the webserver as it is for you, so I would focus my search in those areas.

Epcylon
That was it. I was indeed assuming that PYTHONPATH was working for both myself and the webserver. I didn't think about the PYTHONPATH as being distinct from the webserver process.You can append to the sys.path for the webserver process in the WSGI file using something like this:sys.path.append('/path/to/dir')I did just that, got past that error. Thanks!
Raj