Skip to content

Instantly share code, notes, and snippets.

@muminoff
Created February 26, 2014 05:45
Show Gist options
  • Save muminoff/9224218 to your computer and use it in GitHub Desktop.
Save muminoff/9224218 to your computer and use it in GitHub Desktop.

###How to install Python 2.7.3 on CentOS 6.3

###Install development tools

In order to compile Python you must first install the development tools:

yum groupinstall "Development tools"

You also need a few extra libs installed before compiling Python or else you will run into problems later when trying to install various packages:

yum install zlib-devel
yum install bzip2-devel
yum install openssl-devel
yum install ncurses-devel

###Download, compile and install Python

cd /usr/local/src
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar xf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure --prefix=/usr/local
make && make altinstall

It is important to use altinstall instead of install, otherwise you will end up with two different versions of Python in the filesystem both named python.

(Depending on your version of wget, you may need to add the --no-check-certificate option to the wget command line. Even better, upgrade to a version of wget that handles SNI appropriately.).

After running the commands above your newly installed Python 2.7.3 interpreter will be available as /usr/local/bin/python2.7 and the system version of Python 2.6.6 will be available as /usr/bin/python and /usr/bin/python2.6.

you can create a symbolic link in /usr/local/bin and things should be fine be careful here:

cd /usr/local/bin
ls -ltr python*
ln -s /usr/local/bin/python2.7 /usr/local/bin/python

###Installing and configuring distribute (setuptools)

After installing Python 2.7.3 you also need to install distribute (setuptools) so you can easily install new packages in the right location.

cd /opt
wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.27.tar.gz
tar xf distribute-0.6.27.tar.gz
cd distribute-0.6.27
python2.7 setup.py install

The commands above will generate the script /usr/local/bin/easy_install-2.7. Use this script to install packages for your new Python version. You should be able to use "easy_install" if "which easy_install" points to the correct 2.7 versions

$ which easy_install
/usr/local/bin/easy_install

$ ls -ltr /usr/local/bin/easy_install*
-rwxr-xr-x 1 root root 340 Jan 30  2013 /usr/local/bin/easy_install-2.7
-rwxr-xr-x 1 root root 332 Jan 30  2013 /usr/local/bin/easy_install

easy_install-2.7 requests
easy_install-2.7 psutil
easy_install-2.7 paramiko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment