Question

I am finding it impossible to recompile mod_wsgi for python 2.7.

I am building an application using Flask and Flask-WTF. It works fine as a standalone but breaks in Apache because the the Apache server on my mac is using Python 2.6, even though 2.7 is installed and used in python apps by default. The standalone uses 2.7.

which python shows this:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

otool -L mod_wsgi.so showed this:

 mod_wsgi.so:       

    /System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1)

So I recompiled:

./configure with-python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python

otool -L mod_wsgi.so shows no change:

/System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1)

After a restart, Apache was still using 2.6 as confirmed both by phpinfo() and error logging. The Apache details from phpinfo() are as follows:

Apache/2.2.22 (Unix) DAV/2 mod_wsgi/3.4 Python/2.6.1 PHP/5.3.15 mod_ssl/2.2.22 OpenSSL/0.9.8r

It is using modules found at this path: /Library/Python/2.6/site-packages/. There is no 2.7 directory in /Library/Python.

I have tried fiddling with the WSGIPythonHome variable in httpd.conf, but nothing works.

I also compiled mod_wsgi with the disable-framework command. This did not fix the problem either.

Is there something else I need to change in my Apache configuration to point it to the right python version, or do I need to add something extra to my mod_wsgi configuration? Installing the modules I am using into 2.6 isn't an option.

I am running Apache 2 on Mac OSX 10.6.8

Thanks.


Here's the full solution.

cd <mod_wsgi source directory>

make distclean

./configure --with-python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python --disable-framework

sudo make install
Was it helpful?

Solution

Rebuild mod_wsgi from source code and this time when you run 'configure' add the option '--disable-framework'.

Separate Python installers for Snow Leopard don't always work properly when trying to link to Python as a framework. You therefore need to disable that style of linking so it uses more traditional library linking. This should then result in otool showing it picking up the correct Python version and things should then be okay when used.

You cannot use WSGIPythonHome to force it to use a different version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top