Sunday, May 10, 2015

Installing latest version of python on CentOS 5

http://www.hosting.com/support/linux/installing-python-3-on-centosredhat-5x-from-source

The latest release of the python scripting language is Python 3.2. However due to backwards incompatibilities with Python 2, it has not been adopted for CentOS / Redhat Linux 5. T he primary reason for this, is because release of 'yum' (package management) used in EL5 requires Python 2. Because of this, Python cannot be upgraded in place to version 3 without breaking the package manager.
Therefore to use Python 3, it will need to be installed outside of /usr.

Installing

Below is the list of command (with inline comments) on what is required to compile and install Python 3 from source. The installation will be done into the prefix /opt/python3. This will ensure the installation does not conflict with system software installed into /usr.
# Install required build dependencies
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

# Fetch and extract source. Please refer to http://www.python.org/download/releases
# to ensure the latest source is used.
wget http://www.python.org/ftp/python/3.2/Python-3.2.tar.bz2
tar -xjf Python-3.2.tar.bz2
cd Python-3.2

# Configure the build with a prefix (install dir) of /opt/python3, compile, and install.
./configure --prefix=/opt/python3
make
sudo make install
Python 3 will now be installed to /opt/python3.
$ /opt/python3/bin/python3 -V
Python 3.2
Ensure your python 3 scripts and applications query the correct interpreter.
#!/opt/python3/bin/python3

No comments:

Post a Comment