Mostafa Wattad Mostafa Wattad - 1 year ago 175
Apache Configuration Question

mod_wsgi runtime using old python version

I'm running a django server on httpd service.
I had to upgrade my python version(2.7.12).
After installing the new python I rebuild the mod_wsgi with the new python (using with-python argument).
I also rebuild the mod_python with the new python version.
My new python path is /usr/local/bin/python2.7.
In the /etc/httpd/conf.d/django.conf I added the following line :
WSGIPythonHome /usr/local.

However I see this error in my error_log file (httpd error log):

[Tue Sep 20 12:32:12.743338 2016] [:warn] [pid 8567:tid 139972130834496] mod_wsgi: Compiled for Python/2.7.12.
[Tue Sep 20 12:32:12.743376 2016] [:warn] [pid 8567:tid 139972130834496] mod_wsgi: Runtime using Python/2.7.5.

What i'm missing ?

FYI : I cannot change or redirect the default python that exists in /usr/bin/python because this affect centos package management.

Answer Source

When you install a Python version of the same X.Y version as system Python, but different patch level, you need to force the runtime linker to use the shared Python library from the alternate location of your newer Python version.

To do this, go back and rebuild mod_wsgi but set the LD_RUN_PATH environment variable when building mod_wsgi, to the directory containing the Python library for the alternate Python version.

make distclean
./configure --with-python=/usr/local/bin/python2.7
LD_RUN_PATH=/usr/local/lib make
sudo make install

If this works correctly, you should be able to run:


on the file that was installed and it should be using the Python library from /usr/local/lib and not /usr/lib.

You will also need to still set:

WSGIPythonHome /usr/local
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download