Make mod_wsgi use python2.7.2 instead of python2.6?
Posted
by
guron
on Server Fault
See other posts from Server Fault
or by guron
Published on 2011-06-19T00:55:58Z
Indexed on
2012/07/08
9:17 UTC
Read the original article
Hit count: 218
i am running Ubuntu 10.04.1 LTS and it came pre-packed with python2.6 but i need to replace it with python2.7.2.
(The reason is simple, 2.7 has a lot of features backported from 3 )
i had installed python2.7.2 using
./configure
make
make altinstall
the altinstall option installed it, without touching the system default version, to /usr/local/lib/python2.7 and placed the interpreter in /usr/local/bin/python2.7
Then to help mod_wsgi find python2.7 i added the following to /etc/apache2/sites-available/wsgisite
WSGIPythonHome /usr/local
i start apache and run a test wsgi app BUT i am greeted by python 2.6.5 and not Python2.7
Later i replaced the default python simlink to point to python 2.7
ln -f /usr/local/bin/python2.7 /usr/bin/python
Now typing 'python' on the console opens python2.7 but somehow mod_wsgi still picks up python2.6
Next i tried,
PATH=/usr/local/bin:$PATH
export PATH
then do a quick restart apache, but yet again its python2.6 !!
Here is my $PATH
/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
contents of /etc/apache2/sites-available/wsgisite
WSGIPythonHome /usr/local
<VirtualHost *:80>
ServerName wsgitest.local
DocumentRoot /home/wwwhost/pydocs/wsgi
<Directory /home/wwwhost/pydocs/wsgi>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /home/wwwhost/pydocs/wsgi/app.wsgi
</VirtualHost>
app.wsgi
import sys
def application(environ, start_response):
status = '200 OK'
output = sys.version
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Apache error.log
'import site' failed; use -v for traceback
[Sun Jun 19 00:27:21 2011] [info] mod_wsgi (pid=23235): Initializing Python.
[Sun Jun 19 00:27:21 2011] [notice] Apache/2.2.14 (Ubuntu) mod_wsgi/2.8 Python/2.6.5 configured -- resuming normal operations
[Sun Jun 19 00:27:21 2011] [info] Server built: Nov 18 2010 21:20:56
[Sun Jun 19 00:27:21 2011] [info] mod_wsgi (pid=23238): Attach interpreter ''.
[Sun Jun 19 00:27:21 2011] [info] mod_wsgi (pid=23239): Attach interpreter ''.
[Sun Jun 19 00:27:31 2011] [info] mod_wsgi (pid=23238): Create interpreter 'wsgitest.local|'.
[Sun Jun 19 00:27:31 2011] [info] [client 192.168.1.205] mod_wsgi (pid=23238, process='', application='wsgitest.local|'): Loading WSGI script '/home/wwwhost/pydocs/$
[Sun Jun 19 00:27:50 2011] [info] mod_wsgi (pid=23239): Create interpreter 'wsgitest.local|'.
Has anybody ever managed to make mod_wsgi run on a non-system default version of python ?
© Server Fault or respective owner