Installing Python in Linux or Solaris.
Installing Python in Linux or Solaris can be messy as python is link to the most the system programs.
Here i will show how to install Python at Redhat without un-installing the system in-build python. This tutorial will download the source and build so the same procedure can be use in other distros.
Which version of Python?
I will install here Python 2.7.1 if you want to install any other version, head to python repository and change the version used in this tutorial.
First Check the version installed.
[user@localhost]# python
Most probably it will be version 2.4
Now to install Python Some Pre-installation task need to be perform.
1. Install the necessary Package.
[user@localhost]# yum -y install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-develsqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel make
2. Now Get the Python 2.7 binary and extract it.
[user@localhost]# wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
[user@localhost]# tar xvfz Python-2.7.1.tgz
3. Compile and Install the binary.
[user@localhost]# cd Python-2.7.1
[user@localhost]# ./configure --prefix=/opt/python2.7.1 --with-threads --enable-shared
[user@localhost]# make
[user@localhost]# make install
4. Export the library
[user@localhost]# echo "/opt/python2.7.1/lib/" >> /etc/ld.so.conf.d/opt-python2.7.1.conf
[user@localhost]# /sbin/ldconfig
5. Create Symbolic link so that it can be executed from anywhere.
[user@localhost]#ln -sf /opt/python2.7.1/bin/python /usr/bin/python2.7
6. Now typing python2.7
will give you the python prompt with version 2.7.1
Note: Do not link directly to the “python” to use v2.7 as some system program would use the inbuild python.
Download the script, change the permission and execute it.