Centos 7 minimal ships with python 2.7.5 and using such an old python version can cause problems when using some python packages for network automation. This post describes how to install python 2.7.13 and python 3.6.2 on a Centos 7 minimal server.

Install Python

Install required YUM packages.

sudo yum install -y gcc wget zlib zlib-devel openssl openssl-devel

Use wget to download the python tar files.

cd /tmp

Extract the tar files.

tar -xvf Python-2.7.13.tgz
tar -xvf Python-3.6.2.tgz

Build the python versions and make an alternate install.

cd /tmp/Python-2.7.13
./configure --prefix=/usr/local
sudo make altinstall

cd /tmp/Python-3.6.2
./configure --prefix=/usr/local
sudo make altinstall

sudo make altinstall prevents replacement of the /usr/bin/python binary. Its recommended to leave the system python alone on RHEL distributions as yum uses the system python for updates.

Create a symlink for /usr/bin/python3.6

sudo ln -s /usr/local/bin/python3.6 /usr/bin/python3.6

Note: This is not required for python2.7

Install Pip

Install pip with both python2.7 and python3.6

cd /tmp
wget ""
sudo /usr/local/bin/python2.7
sudo /usr/local/bin/python3.6

Create symlinks for pip

sudo ln -s /usr/local/bin/pip2.7 /usr/bin/pip2
sudo ln -s /usr/local/bin/pip3.6 /usr/bin/pip3

Upgrade PIP and Setuptools

Old versions of setuptools and pip can also cause issues with some network automation libraries so update them with pip

sudo pip2 install -U pip setuptools
sudo pip3 install -U pip setuptools


Confirm python and pip versions.

python2.7 --version
# output
Python 2.7.13

python3.6 --version
# output
Python 3.6.2

pip2.7 --version
# output
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)

pip3.6 --version
# output
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

Clean up

cd /tmp
 rm -f
 sudo rm -rf Python-*


There it is, modern python versions installed on Centos 7 minimal the traditional way. This post is mostly for documentation, in practice you would use your configuration management tools to install these versions of python.


Updated: 2017-10-01

Originally published: 2017-09-14