I am running a Debian Lenny box, which comes with Python 2.5.2. I would like to run Python 2.7 for my WSGI apps only, keeping 2.5 as default for the system, but I cannot get it to work.
First, I installed Python 2.7.2 from source into /usr/local
:
Python-2.7.2 # ./configure --enable-shared
[…]
Python-2.7.2 # make
[…]
Python-2.7.2 # make altinstall
[…]
Calling python2.7
now from the command line works without any problems. It also finds packages installed via pip
in /usr/local/lib/python2.7/packages
.
Next, I built mod_wsgi
and copied it manually to the Apache module directory, so as not to touch files placed by apt-get
.
mod_wsgi-3.3 # ./configure --with-python=/usr/local/bin/python2.7
[…]
mod_wsgi-3.3 # make
[…]
mod_wsgi-3.3 # cp .libs/mod_wsgi.so /usr/lib/apache2/modules/mod_wsgi.so-2.7
mod_wsgi-3.3 # cd /usr/lib/apache2/modules
modules # ln -sf mod_wsgi.so-2.7 mod_wsgi.so
modules # ldd mod_wsgi.so-2.7
linux-vdso.so.1 => (0x00007fff08f53000)
libpython2.7.so.1.0 => /usr/local/lib/libpython2.7.so.1.0 (0x00002b0317e1f000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00002b03181fd000)
libdl.so.2 => /lib/libdl.so.2 (0x00002b031841a000)
libutil.so.1 => /lib/libutil.so.1 (0x00002b031861e000)
libm.so.6 => /lib/libm.so.6 (0x00002b0318821000)
libc.so.6 => /lib/libc.so.6 (0x00002b0318aa5000)
/lib64/ld-linux-x86-64.so.2 (0x00002b03179cd000)
I then modified /etc/apache2/mods-available/wsgi.conf
and added the following directive:
<IfModule mod_wsgi.c>
[…]
WSGIPythonHome /usr/local
[…]
</IfModule>
(Of course, wsgi.conf
is symlinked in /etc/apache2/mods-enabled
.)
Finally, I restarted apache, but my WSGI scripts won’t run. I get the following traceback in Apache’s error log:
mod_wsgi (pid=20746): Exception occurred processing WSGI script '/path/to/script.wsgi'.
Traceback (most recent call last):
File "/usr/local/lib/python2.5/site-packages/Flask-0.7.2-py2.5.egg/flask/app.py", line 1306, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.5/site-packages/Flask-0.7.2-py2.5.egg/flask/app.py", line 1295, in wsgi_app
return response(environ, start_response)
File "/usr/local/lib/python2.5/site-packages/Werkzeug-0.6.2-py2.5.egg/werkzeug/wrappers.py", line 1017, in __call__
start_response(status, headers)
TypeError: expected byte string object for status, value of type str found
I also tried the test WSGI script found in the Installation Issues section of mod_wsgi
’s documentation, but I get the same TypeError
here. Judging from the traceback, I would guess that Apache now runs Python 2.5 in combination with mod_wsgi
compiled for 2.7.
Any ideas?