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

I have an Arch Linux server that used to use Python 2.7.3 just fine with Apache and mod_wsgi-3.4-2. I have both Python 2.7.3 and 3.3.0 installed on the server, and both executables are located in /usr/bin. Recently it has started to use Python 3. I need Apache to go back to using Python 2.7. The error_log looks something like this on a single request:

[Thu Dec 13 00:18:50 2012] [notice] Apache/2.2.23 (Unix) mod_wsgi/3.4 Python/3.3.0 mod_ssl/2.2.23 OpenSSL/1.0.1c DAV/2 PHP/5.4.9 configured -- resuming normal operations
[Thu Dec 13 00:18:53 2012] [error] 3.3.0 (default, Sep 29 2012, 16:08:02) 
[Thu Dec 13 00:18:53 2012] [error] [GCC 4.7.1 20120721 (prerelease)]
[Thu Dec 13 00:18:53 2012] [error] 
[Thu Dec 13 00:18:53 2012] [error] [client 192.168.0.7] mod_wsgi (pid=6156): Target WSGI script '/path/to/webapp/apache/wsgi.py' cannot be loaded as Python module.
[Thu Dec 13 00:18:53 2012] [error] [client 192.168.0.7] mod_wsgi (pid=6156): Exception occurred processing WSGI script '/path/to/webapp/apache/wsgi.py'.
[Thu Dec 13 00:18:53 2012] [error] [client 192.168.0.7] Traceback (most recent call last):
[Thu Dec 13 00:18:53 2012] [error] [client 192.168.0.7]   File "/path/to/webapp/apache/wsgi.py", line 4, in <module>
[Thu Dec 13 00:18:53 2012] [error] [client 192.168.0.7]     from django.core.handlers import wsgi
[Thu Dec 13 00:18:53 2012] [error] [client 192.168.0.7] ImportError: No module named 'django'

Here's my wsgi.py file:

import os
import sys
from django.core.handlers import wsgi

site_path = '/path/to/webapp/csis3150site'
if site_path not in sys.path:
  sys.path.append(site_path)

# Set DJANGO_SETTINGS_MODULE env variable
os.environ['DJANGO_SETTINGS_MODULE'] = 'csis3150site.settings'

# start wsgi
application = wsgi.WSGIHandler()

This is the mod_wsgi-related configuration from httpd.conf:

LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /path/to/webapp/apache/wsgi.py 
WSGIPythonPath /path/to/webapp
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I was able to fix this be uninstalling the mod_wsgi package and replaced it with the mod_wsgi2 package.

share|improve this answer
add comment

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.