apache2 mod_python version mismatch

I was getting some warnings in one machine’s Apache 2 web server error log regarding mod_python, see below:

[Wed Jan 25 01:29:11.717727 2017] [:error] [pid 4389] python_init: Python version mismatch, expected '2.7.5+', found '2.7.9'.
[Wed Jan 25 01:29:11.717856 2017] [:error] [pid 4389] python_init: Python executable found '/usr/bin/python'.
[Wed Jan 25 01:29:11.717864 2017] [:error] [pid 4389] python_init: Python path being used '/usr/lib/python2.7/:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload'.

The issue is with libapache2-mod-python. The Python version installed in the system is newer than the one mod_python was built for.  Of course, 2.7.9 is newer than 2.7.5+, as required, so the module works, and the error part should be a warning, not an error.  A bug has been reported for this issue for Ubuntu in Launchpad (bug 1073147), but applies to Debian as well.

Two comments in that thread are key if you are facing this issue, comments #1 and #8.  I am also pasting those here as well for posterity (and to quickly remind myself what I did to fix the issue):

#1 Matthias Klose (doko)

known issue, however it's a warning, the module continues to work.

#8 Robert Hernandez (0-robert)

# You have to recompile mod-python and/or mod-wsgi.
# Remove mods
apt-get remove libapache2-mod-python libapache2-mod-wsgi
# Get dependencies
apt-get build-dep libapache2-mod-python libapache2-mod-wsgi
# Build mod-python
mkdir /tmp/python
cd /tmp/python
apt-get source libapache2-mod-python
cd libapache2-mod-python-[x.x.x]
dpkg-buildpackage -rfakeroot -b
#Build mod-wsgi
mkdir /tmp/wsgi
cd /tmp/wsgi
apt-get source libapache2-mod-wsgi
cd mod-wsgi-[x.x.x]
dpkg-buildpackage -rfakeroot -b
# Install newly compiled packages
dpkg -i /tmp/python/libapache2-mod-python-[x.x].deb /tmp/wsgi/libapache2-mod-wsgi-[x.x].deb

Credit goes to all who commented in that thread and helped solve this issue.

The solution proposed worked for me on Debian Wheezy 7.11 amd64 on 2017.01.25 & Debian Jessie 8.7 amd64 on 2017.01.25.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.