How do I get Apache to run 2.7 rather than 2.5?

I'm configuring Apache to use mod_wsgi with Django and Python 2.7, but error logs show Apache is using Python 2.5.2 and can't find django.core.handlers.wsgi.

The module is available to the python and django shells, each running 2.7, so I think the problem is Apache's python version.

I installed Python 2.7.1 from source (on a Debian system), and changed the symlink /usr/bin/python to point to /usr/local/bin/python2.7, where 'make install' put the binary. Both the python and django shells bring up 2.7.1 (these can import the wsgi module).

Possibly related -- when I shift the symlink back to the prior version (required by apt-get for some installs), the python shell still comes up 2.7.1. Django does not. Did I miss something in my install process?

UPDATE: This -- https://stackoverflow.com/questions/4186099/django-running-wrong-version -- suggests that the problem could be that mod_wsgi,or mod_python, are built for Python 2.5.

I've tried building mod_wsgi from source, but that process wasn't finding apxs, and efforts to install libapache2-dev (as suggested by the mod_wsgi site) were bombing on uninstallable dependencies. And I can't install mod_wsgi or mod_python via apt-get without pointing Python to the debian default of 2.5. Not sure how to get unstuck here.

UPDATE 2: Chose to rollback Python to 2.5.

I speculate that Apache was going into Python 2.5 b/c it was finding mod_wsgi.so-2.5, corresponding to Python 2.5, in mods-enabled. Compilation of mod_wsgi might have put a .so-2.7 module there, but this required apache2-dev, and the Debian package for this was breaking on some missing dependency issue, and rollback judged the better part of valor, and none will ever care about that or this run-on recap but if, gentle reader, some python2.7 + apache hairball brings you here and the annotation of these time-scars spares you a moment, raise a glass for me. excelsior! good night.

UPDATE LAST: The apache2-dev issue was resolved by installing via aptitude, rather than apt-get.

2 Answers 2


Is there a real reason you need Python 2.7? Django can be installed for 2.5, and the Debian packages will keep security related patches applied to python 2.5. Why not just keep everything stock from Debian's repositories, and install Django for 2.5? That will save you quite a bit of compiling things from source, making installation easier, It will also keep upgrades and maintenance far simpler, and less likely to break in the future.

--Christopher Karel

  • Synchronization. Tests passing on a dev box, running 2.6 (Ubuntu), were breaking on the server, running 2.5 (Debian). So I thought I'd upgrade both to 2.7, simplistically thinking it wouldn't be that hard and that things were moving to 2.7 anyway. Oops. I suppose I could roll everything back down to 2.5, but this seems like the last problem and solving it less work than a rollback.
    – chernevik
    Feb 22, 2011 at 17:23

Is /usr/bin/python the only "executable"?

What does

ls -l /usr/bin/python* 

show? And

ls -l /usr/bin/X11/python* 


type -a python


  • ls -l: /usr/bin/python -> /usr/local/bin/python2.7. type -a python: python is /usr/local/bin/python, python is /usr/bin/python. No file /usr/bin/X11/python
    – chernevik
    Feb 22, 2011 at 17:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .