mod_wsgi isn't honoring WSGIPythonHome

zigdon picture zigdon · Dec 28, 2011 · Viewed 16.1k times · Source

I'm trying to get WSGI to run with a virtualenv setup. I have the virtualenv all working right:

(virtualenv)dev:/var/www/app$ which python
/var/www/virtualenv/bin/python
(virtualenv)dev:/var/www/app$ python
Python 2.6.1 (r261:67515, Dec  5 2008, 22:09:34)
[GCC 4.1.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib
>>>

And in my httpd.conf, I have the following, as described here:

WSGIPythonHome /var/www/virtualenv
WSGIPythonPath /var/www/virtualenv/lib/python2.6/site-packages

But when I try to load the app via apache, i get the following error:

[Wed Dec 28 12:28:15 2011] [error] [client 127.0.0.1] mod_wsgi (pid=15026): Exception occurred processing WSGI script '/var/www/app/wsgi.py'.
[Wed Dec 28 12:28:15 2011] [error] [client 127.0.0.1] Traceback (most recent call last):
[Wed Dec 28 12:28:15 2011] [error] [client 127.0.0.1]   File "/var/www/app/wsgi.py", line 29, in <module>
[Wed Dec 28 12:28:15 2011] [error] [client 127.0.0.1]     import importlib
[Wed Dec 28 12:28:15 2011] [error] [client 127.0.0.1] ImportError: No module named importlib

What am I missing? How do even debug this kind of problem?

Answer

Graham Dumpleton picture Graham Dumpleton · Dec 29, 2011

Your mod_wsgi is likely compiled against a different Python version than you are trying to force it to use. For example, you can not use mod_wsgi compiled against Python 2.4 with a virtual environment constructed using Python 2.6.

Validate what version of Python mod_wsgi was built for in the first place.