Step-by-step guide on how to install optional Python version on CentOS server

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasises readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all the key platforms and can be freely distributed.

By default on CentOS or any other popular Linux distribution Python, 2.6 version is installed.

You can check the current version with the following command:

~]# python -V
Python 2.6.6  

Install optional Python version from IUS Community repository

To install Python 2.7 on the server, please do the following:

Log in as root (superuser) and push:

cd /root ; wget -c ; rpm -ivh ius-release.rpm  

On CentOS 7:

cd /root ; wget -c ; rpm -ivh ius-release.rpm  

After IUS Community repositories are successfully installed ( you need to run the following commands:
yum -y install python27 python27-devel python27-pip python27-setuptools python27-virtualenv --enablerepo=ius

After packages get successfully installed, you can test if python2.7 and pip are working as expected, for example:

[root@second ~]# python2.7 -V
Python 2.7.13

[root@second ~]# pip2.7
pip <command> [options]

[root@second ~]# virtualenv-2.7
You must provide a DEST_DIR  
Usage: virtualenv-2.7 [OPTIONS] DEST_DIR  
--version show program's version number and exit
-h, --help show this help message and exit
-v, --verbose Increase verbosity.
-q, --quiet Decrease verbosity.

You may create an alias within the username by adjusting .bashrc file for python and virtualenv with the optional Python 2.7 version, for example:
alias python='/usr/bin/python2.7'
alias virtuelenv='/usr/bin/virtualenv-2.7'

Repeat procedure In case you wish optional Python3+ version installed.

Related articles

Install optional Python version from Software Collections (SCL) Repository

Software Collections give you the power to build, install, and use multiple versions of software on the same system, without affecting system-wide installed packages.

To install Python 2.7 on CentOS server, please do the following:

Install The Software Collections ( SCL ) Repository:

yum install centos-release-scl  

Install python27 from SCL repository:

yum install python27 -y  

Enable python27 with the following command:

scl enable python27 bash  

Test active Python version:

python -V  

The System should return "Python 2.7.X" Where X is the latest version of python in this branch.

Related article:

Install optional Python version using Anaconda

With Anaconda you can run multiple versions of Python in isolated environments, so choose the download with the Python version that you use more often, as that will be your default Python version.

If you don't have the time or disk space for the entire distribution, try Miniconda ( which contains only conda and Python. Then install just the individual packages you want through the conda command.

1) Linux installer at
2) Run the provided bash command from above to start the installer:


For Python 2.7 version:


3) Agree to the license agreement
4) Set the install location on /home somewhere, like 5) /home/anaconda3
6) Add to bashrc when prompted.
7) Exit current user and relog or source bashrc
8) run "python -V" and you should see 3.6.1 (latest version)

Anaconda is BSD licensed which gives you permission to use Anaconda commercially and for redistribution.

Related article:

These are three known methods I've selected if you need optional Python versions on your server installed. Of course, you can compile, but who needs that when you can use different repositories to complete the task.