Redhat – Upgrading Python on RHEL5

pythonredhat

I have python 2.4 and 2.6 installed on my RHEL5 machine.

But

[de22596 gnuradio]:+ss$ python -V
Python 2.4.3

I tried to make a symlink from in /usr/bin python -> python26, then I get

[de22596 gnuradio]:+ss$ python -V
Python 2.6

But a lot of things break, like yum. How can I fix this?

Right now, I have this:

[de22596 bin]:$ ls -l python*
lrwxrwxrwx 1 root root    9 Jul 20 10:52 python -> python2.4
lrwxrwxrwx 1 root root    6 Jul 12 15:02 python2 -> python
-rwxr-xr-x 2 root root 8304 Jun 11  2009 python2.4
-rwxr-xr-x 2 root root 8328 Apr  9 11:17 python26
-rwxr-xr-x 2 root root 8328 Apr  9 11:17 python2.6
-rwxr-xr-x 1 root root 1418 Apr  9 11:17 python2.6-config
-rwxr-xr-x 2 root root 8304 Jun 11  2009 python.back
lrwxrwxrwx 1 root root   16 Jul 20 10:34 python-config -> python2.6-config

Could I do

yum remove python2.4

And expect things to still work? I'm worried because yum is a python script, so if I remove python2.4 will it be smart enough to

Best Answer

Unfortunately, you cannot remove Python 2.4 from RHEL5, unless you're able to remove (or patch) dozens of Python scripts that only work with 2.4, not 2.6. You can easily install 2.6 in parallel with 2.4 (as you already know), but removing 2.4 is "major surgery". You can certainly try, but most users/operators just don't bother.

As another poster noted, '/usr/bin/python26' is in your default PATH, just like '/usr/bin/python'. On the command line, you can just call 'python26' instead of 'python'. In your 2.6-specific scripts/programs, you can replace your she-bang lines with '#!/usr/bin/python26'.

Handling 2.6-only modules is a bit harder. You'll need to move them from '/usr/lib/python/...' to '/usr/lib/python26/...'. If you're lucky, somebody may have already packaged a variant specifically for Python 2.6 on RHEL5 with the paths changed, or you can modify and rebuild existing RPMs, yourself.

The problem is that the transition from Python 2.4 to 2.6 introduced a few backward-incompatibilities. So a lot of scripts authored with 2.4 in mind won't run properly under 2.6 without some patching. (There are people who claim that 2.6 IS backwards compatible... it's close, but not 100%.)

Recent Fedora releases and the RHEL6 beta ship more advanced Python versions (2.5+), along with updates to dozens (possibly hundreds) of Python scripts, too. But Red Hat decided to keep its EL5 branch on Python 2.4, probably due to the risk of breaking any Python 2.4-only scripts running on clients' machines. (This is a pretty standard practice for a long-term-stable distro series like RHEL.)

Related Topic