Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
share|improve this question
1  
How about posting the contents of wsgi_handler.py? –  tfitzgerald Aug 26 '12 at 17:11

3 Answers 3

Sounds like whatever software you are trying to host depends on and needs you to install django or some of it's supporting modules for apache. Look into installing these through your distro's package manager.

share|improve this answer
    
I 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? –  bigmac Apr 21 '11 at 10:40
    
Upgrade 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. –  Caleb Apr 21 '11 at 10:59

Look at the WSGIPythonExecutable and WSGIPythonPath apache directives.

Be aware that mod_python and mod_wsgi are mutually exclusive.

share|improve this answer
1  
WSGIPythonExecutable doesn't exist in latest mod_wsgi versions. And mod_python and mod_wsgi are not mutually exclusive if set up right. –  Graham Dumpleton Mar 16 '12 at 15:44

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')
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.