Take the 2-minute tour ×

I would like to upgrade python for django. Currently I have python 2.4.3 on my Red Hat server. I have installed python 2.7.1, but the default python is still 2.4.3 (It didn't upgrade python, but installed python 2.7 separately). Django python version is also still 2.4.3 as well. I want to make a change so Django runs with 2.7. How do I overcome this problem?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

RedHat has many tools that depend on Python 2.4 (yum is an example of this) so make sure you don't overwrite the standard Python binary.

Depending on how you installed it, you may be able to get to it with the command python27 or python2.7. So instead of running
python ./djangoapp.py
python2.7 ./djangoapp.py

If that doesn't work, you might need to reference the Python binary directly as it might not be in the system path. From memory, it should be something like /installpath/bin/python. You might want to symlink that into /usr/bin or something so it's available in your system path, just make sure to name it python2.7 or python27 not just Python.

share|improve this answer
@samarudge Sorry to ask you this noob question, but when you run python2.7 ./djangoapp.py, do you use this step in the configure process? If I past this line in my terminal and run it I get python2.7: can't open file './djangoapp.py': [Errno 2] No such file or directory –  Shehzad009 Jun 13 '11 at 9:30
@Shehzad009 No that's nothing to do with setting it up, when you run python2.7 --version does it print back the correct version number? If so, everything is working, but when you launch your django app instead of using the python command use the python2.7 command –  sam Jun 13 '11 at 9:33
@samarudge Running this python2.7 --version works. Typing python2.7 ./djangoapp.py does not work. python2.7: can't open file './djangoapp.py': [Errno 2] No such file or directory –  Shehzad009 Jun 13 '11 at 9:42
@Shehzad009 I was using ./djangoapp.py as an example, you should replace it with the path to your django application's main file. That means you have Python 2.7 working correctly you just need to run your application with it –  sam Jun 13 '11 at 9:46
@samarudge so if my project folder is c2duo_mms, and my inside this folder I have an mmc folder which holds my forms/views/models - etc. So I should replace djangoapp.py with mmc? EDIT: I get this error. /usr/local/bin/python2.7: can't find '__main__' module in './mmc' –  Shehzad009 Jun 13 '11 at 9:51
show 1 more comment

You should really consider running virtualenv, located on PyPi. It sets up a virtual environment for running different versions of Python, which allows you to avoid interfering with the system's Python 2.4.

I have the same problem on my CentOS VPS, and found virtualenv as the solution. It's not quite as simple as everyone says (when you build third-party packages that aren't Python-based, say that compile in C, you have to make sure they point to the right Python libraries for compilation). But it generally works nicely.

share|improve this answer
add comment

Your Answer


