
I work with some smart folks who need the latest stuff to get the job done. However, this can sometimes be a problem when you use a more conservative (read: stable) Linux distribution like CentOS.
You see, CentOS 5 comes bundled with Python 2.4 where Fedora or Ubuntu (or Linux Mint) ship with Python 2.6.
(nathan@citadel:~)$ cat /etc/issue
Linux Mint 9 Gloria - Main Edition \n \l
(nathan@citadel:~)$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
(nathan@test1:~)$ cat /etc/issue
CentOS release 5.5 (Final)
(nathan@test1:~)$ python
Python 2.4.3 (#1, Sep 3 2009, 15:37:37)
CentOS has several subsystems (like yum) and a whole pool of packages which expect and rely on Python 2.4 to be installed. I’d really hate to mess with that, so when Outbrain‘s braintrust (har har) says they need a particular functionality from Python 2.6 I choose to alt-install thus:
yum -y install gcc
wget http://python.org/ftp/python/2.6.4/Python-2.6.4.tgz
tar zxvf Python-2.6.5.tgz -C /usr/src && cd /usr/src/Python-2.6.5
./configure
make
make altinstall
Easy, huh?
So, 2.4 is the default, remember?
(nathan@test1:~)$ python
Python 2.4.3 (#1, Sep 3 2009, 15:37:37)
But if you want 2.6, you need to explicitly define the 2.6 binary:
(nathan@test1:~)$ python2.6
Python 2.6.4 (r264:75706, Feb 23 2010, 10:34:37)
This means if you want your script to run 2.6 you need to change your magic from
#!/usr/bin/env python
to
#!/usr/bin/env python2.6
Et voilà!