How To Install Python 3 on CentOS 7

Install Python 3 on CentOS 7

In this tutorial, we will show you how to install and configure Python 3 on CentOS 7. Python is a versatile and powerful programming language that has gained immense popularity in recent years. It is widely used in various domains, including web development, data analysis, machine learning, and automation. If you’re using CentOS 7 and want to take advantage of Python’s capabilities, you’ll need to install Python 3 on your system.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Python on a CentOS 7 server.


  • A server running one of the following operating systems: CentOS 7.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Python 3 on CentOS 7

Step 1. First, let’s start by ensuring your system is up-to-date.

yum -y update
yum groupinstall "Development tools"

Step 2. Installing required packages and dependencies.

Before compiling Python from the source code, you need to install some required packages and dependencies. Run the following command:

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

Step 3. Installing Python on CentOS 7.

Method One: Build and Install Python3 from the Source

The first thing to do is to go to Python’s download page and download the latest stable version of Python, At the moment of writing this article it is version 3.9.9:

wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz

Extract source archive and build:

tar xzf Python-3.9.9.tgz
cd Python-3.9.9

Next, we are going  to configure the installation directory  on /usr/local, We can change the path:

./configure --prefix=/usr/local

Building and installing Python through the below make altinstall command, this command will replace the python, which is used by the server:

make altinstall

You now should be all set to use your newly compiled Python version:

#  python3.9 –V
Python 3.9.9

Method Two: Install Python3 from EPEL Repository

First, you need to enable the EPEL repository on your system:

yum install epel-release

Then install Python 3.9 and its libraries using yum:

yum install python39

Method Three: Install Python3 from Software Collections (SCL)

The first step is to install the utilities needed to manage collections:

yum -y install scl-utils

Once you enable the SCL repository, go ahead and install python3 as follows:

yum -y install python39

Python 3.3 will become accessible by launching a new shell instance using the Software Collection scl command:

scl enable python39 bash

Additional Python libraries and tools, such as pip, can now be installed:

easy_install pip

Remember to keep your Python installation up-to-date by regularly checking for new releases and applying security patches. Additionally, consider exploring the vast ecosystem of Python libraries and frameworks to enhance your development experience and tackle various tasks more efficiently.

Congratulations! You have successfully installed Python. Thanks for using this tutorial for installing Python 3 on CentOS 7 system. For additional help or useful information, we recommend you check the official Python website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button