Apache mod_wsgi error: ImportError: No module named django.core.handlers.wsgi
7,526
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 videos on Youtube
Author by
bigmac
Updated on September 18, 2022Comments
-
bigmac over 1 year
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
-
tfitzgerald over 11 yearsHow about posting the contents of wsgi_handler.py?
-
-
bigmac about 13 yearsI think the problem is that I have installed Python 2.7 and the mod_wsgi is looking at Python2.5 site-packages. Is there some way I can change this?
-
Caleb about 13 yearsUpgrade
mod_wsgi
to a version that knows what to do with Python 2.7. If you upgrade all the packages in your distribution, this shouldn't happen. If you have manually installed python without using your distros packages, you might have to do the same for everything that depends on it.