Running multiple Python versions on CentOS6/RHEL6/SL6
The default RHEL6.x installation comes with python 2.6.6 but some people (mostly developers) need newer versions of python (either 2.7.3 or 3.3). Upgrading the existing python packages is not recommended as it would likely cause issues with the OS, so the only way is to install the other version(s) alongside with the existing one. While some have the knowledge to compile or build the new packages themselves, others would prefer to go the easier way and use a package repository to install software on their machines.
Since the official repos only provide python 2.6.6 they’d need a 3rd-party repository to get newer python packages and luckily there is one called PUIAS (created and maintained by members of Princeton University and the Institute for Advanced Study) and it’s fully compatible with RHEL6 / CentOS6.
Install PUIAS repository
What you need for python packages is puias-computational repository which contains scientific and research packages. According to their instructions page they provide an rpm package to automatically install and configure the repo, but as of today the link is broken so you’d have to do it manually.
Here’s how:
- download and import the rpm gpg key
cd /etc/pki/rpm-gpg/ wget -q http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias rpm --import RPM-GPG-KEY-puias
As an optional step to confirm the rpm key has been imported successfully:
gpg --quiet --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
- create the repository file as /etc/yum.repos.d/puias-computational.repo
cat /etc/yum.repos.d/puias-computational.repo [PUIAS_6_computational] name=PUIAS computational Base $releasever - $basearch mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist #baseurl=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias
- confirm the repo is functional (optional)
yum repolist | grep -i puias * PUIAS_6_computational: puias.math.ias.edu PUIAS_6_computational PUIAS computational Base 6 - x86_64 1,455
You can now search for python 2.7.3 and / or 3.3 packages to see what rpms are available for download.
yum search python27 yum search python3
I chose to install both versions and their IDLE environment:
yum install python27 python3 python27-tools python3-tools
The result is really satisfying, I can now run python-2.6.6, python-2.7.3 and python-3.3 on the same machine at the same time on my CentOS 6.4 installation.
Hope this helps. Cheers!
Thanks man!
Nice tip, works with a charm!
It’s only hard to copy and past stuff from your website, hahahaha…
Cheers!
Looks like your editor ate a redirect? Greater-than sign in :
cat ‘>’ /etc/yum.repos.d/puias-computational.repo