By default, CentOS 6 comes with Python 2.6. This manual is only for those, who want a newer version of the software.
You can check which version is currently installed by opening the terminal and executing the command python –version.
How to install Python on CentOS 6
Execution of each of these commands can take up to several minutes.
- Update all packages with
yum update
- Install zlib-devel module:
yum install zlib-devel
- Install openssl-devel module:
yum install openssl-devel
- Check the compiler version:
gcc –v
- If you need to, install the compiler:
yum install gcc
- Download Python from the official source:
cd /tmp/ wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
- Unpack it and go to the unpacked folder:
tar xfp Python-2.7.9.tgz
cd Python-2.7.9
- Check the dependencies and execute makefile:
./configure cat Makefile | grep prefix ./configure -h | grep prefix
- Create the installation package:
make
- Install it:
make install
After you are done, Python will be updated to the latest version.