python

Install python-2.7 and fabric on CentOS-5.6

Install the required packages first:

# yum install gcc gcc-c++.x86_64 compat-gcc-34-c++.x86_64 openssl-devel.x86_64 zlib*.x86_64

Download and install python-2.7 from source:

$ wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
$ tar -xvzf Python-2.7.2.tgz
$ cd Python-2.7.2
$ ./configure --with-threads --enable-shared
$ make
# make install

Link the shared library:

# echo "/usr/local/lib" >>/etc/ld.so.conf.d/local-lib.conf
# ldconfig

Verify with:

$ which python
$ python -V

Install easy_install:

$ wget http://peak.telecommunity.com/dist/ez_setup.py
# python ez_setup.py

Install fabric via easy_install:

easy_install fabric

To get the location of site-packages for current version of python:

$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

Switching between python versions

If you've installed a different version of python via yum using pyvault repos, then you need to switch the default python back to the systems default to avoid problems with the OS packages.

Install the alternatives first:

# alternatives --install /usr/bin/python python /usr/bin/python2.3 100
# alternatives --install /usr/bin/python python /usr/bin/python2.4 24

where 100 and 24 are the priority numbers (Higher number prevailing).

Remove existing symlinks:

# rm /usr/bin/python

Configure the default:

# alternatives --config python

Or, set it to create automatically, which will use the highest priority:

# alternatives --auto python

Check with:

$ python -V

Comment