Python – How is it possible for mod_wsgi to be compiled against Python 2.7.3 but use the 2.7.2 runtime

apache-2.2djangopython

The following is what appears in my error_log:

[Sat Nov 17 23:13:14 2012] [warn] mod_wsgi: Compiled for Python/2.7.3.
[Sat Nov 17 23:13:14 2012] [warn] mod_wsgi: Runtime using Python/2.7.2.

If I check my $PATH variable and even in /etc/paths, /usr/local/bin (which contains Python 2.7.3) comes before /usr/bin (which contains Python 2.7.2).

Is there some other path that I'm missing out on? How can I get the correct runtime to be used?

Best Answer

I was able to determine the reason why the older runtime was used.

The quick fix was to symlink /usr/bin/python (which was originally 2.7.2) to /usr/local/bin/python where the newer version of Python is making /usr/bin/python also 2.7.3. Upon restarting Apache, 2.7.3 was used meaning somehow /usr was being used over /usr/local. However, I didn't want to stick with this as the solution, so I removed the symlink.

After some further digging, I looked at the apachectl script and was able to determine that it was loading environment variables for Apache from /usr/sbin/envvars

I modified the following line of the envvars file to include /usr/local/lib and restarted Apache. It loaded with Python 2.7.3 (thus solving a separate issue with _uname I was having with Django that is caused by 2.7.2/2.7.3 discrepancies)

DYLD_LIBRARY_PATH="/usr/local/lib:/usr/lib:$DYLD_LIBRARY_PATH"