How to Install Python 3.6 on CentOS 6

CentOS 6 has Python 2.6.6 pre-installed which can’t be upgraded. Forcefully upgrading or replacing this version causes yum and many other utilities to break.  In this tutorial we will install a new version of python using alternate install method. This will create a new python version in /usr/local.

In This Guide:

Quick Reference:

Python installation dir /usr/local/lib/python3.6
Python executable /usr/local/bin/python3.6
Pip executable /usr/local/bin/pip3.6

Step 1 – System Package Installation

Install below pre-requisites:

sudo yum -y install gcc openssl-devel bzip2-devel

Step 2 – Downloading Python

Download python

cd /tmp/
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz

Step 3 – Python Alternate Installation

tar xzf Python-3.6.6.tgz
cd Python-3.6.6
./configure --enable-optimizations
sudo make altinstall

Step 4 – Verifying new version

python3.6 -V
Python 3.6.6

Shell Script Shortcut

Warning: Never run shell scripts downloaded from internet. Fork or download below script, review and keep your own local copy.

https://github.com/vinodpandey/scripts/blob/master/python3-centos-6.sh

 

Leave a Comment