I am running Apache httpd 2.4.4 on a RedHat 5 machine. I am using Django and running through mod_wsgi. I have Python 2.4.3 installed in /usr/bin and Python 2.7.6 installed in /usr/local/bin and I want to use 2.7.6. I build the 2.7.6 from source and also built mod_wsgi-3.4.
I have created a virtualenv using 2.7.6 and from a command shell, python -V tells me it's using 2.7.6 (after doing a
. virtpy/bin/activate). Running
import sys; sys.version shows me 2.7.6 as well, and
sys.executable shows me
When I run it from httpd, I get problems loading libraries and when I look at
sys.version, I see 2.7.3. The weird thing is that
sys.executable still shows me
/www/sqla/virtpy/bin/python, exactly the same one as I see from the command shell.
Specifically, when python tries to load _socket, I see this error from httpd:
ImportError: /www/sqla/virtpy/lib/python2.7/lib-dynload/_socket.so: undefined symbol: _PyInt_AsInt
If I try to import _socket from a command shell, no problem. I have
. /www/sqla/virtpy/bin/activate in my /etc/sysconfig/httpd and have restarted Apache with that change.
How can the same executable give different versions of python? How can I convince it to use the right one?