Apache mod_wsgi error: ImportError: No module named django.core.handlers.wsgi

apache-2.2djangomod-wsgi

I am using Python 2.7 with mod_python 3.3.1 and mod_wsgi 3.3.

I get an Internal Server Error and this stack trace in the apache logs:

[Thu Apr 21 10:25:37 2011] [error] [client 83.244.243.242]     import django.core.handlers.wsgi [Thu Apr 21 10:25:37 2011] [error] [client
83.244.243.242] ImportError: No module named django.core.handlers.wsgi [Thu Apr 21 10:25:37 2011] [error] [client
83.244.243.242] mod_wsgi (pid=4463): Target WSGI script '/home/one/codebase/campman/wsgi_handler.py' cannot be loaded as Python module. [Thu Apr 21 10:25:37 2011] [error] [client 83.244.243.242] mod_wsgi (pid=4463): Exception occurred processing WSGI script '/home/one/codebase/campman/wsgi_handler.py'. [Thu Apr 21 10:25:37 2011] [error] [client 83.244.243.242] Traceback (most recent call last): [Thu Apr 21 10:25:37 2011] [error] [client
83.244.243.242]   File "/home/one/codebase/campman/wsgi_handler.py", line 13, in <module> [Thu Apr 21 10:25:37 2011] [error] [client
83.244.243.242]     import django.core.handlers.wsgi [Thu Apr 21 10:25:37 2011] [error] [client
83.244.243.242] ImportError: No module named django.core.handlers.wsgi

Best Answer

You may need to tell your WSGI handler where to look for site-packages:

import site
site.addsitedir('/path/to/lib/python2.7/site-packages')
Related Topic