This tutorial describes how to install Python 3.9 on CentOS 8 and RHEL 8 systems. In this tutorial, we will install Python from the source code.


This Python installation required the GCC compiler on your system. Login to your server using ssh or shell access. Now, use the following command to install prerequisites for Python before installing it.

Step 1 – Download Python 3.9

Visit the official download site to download the latest or required version of the Python. Command line users can download Python 3.9 via command line: Then, extract the archive file on your system This will create a directory named Python-3.9.6 in the current directory containing all source files for Python 3.9.

Step 2 – Install Python on CentOS 8

Change directory to Python-3.9.6. Then prepare the source code with the required values before compiling it. Next, compile the source code with make. Here nproc will provide the number of CPU cores available on system. So that make can perform well. Now, we don’t need the downloaded archive file, so delete it to free space.

Step 3 – Test Python Version

At this step, you have successfully installed Python 3.9 on CentOS/RHEL system. Now, check the installed versions of Python and PIP. Check Python Version: Check PIP Version:

Step 4 – Create Virtual Environment

It is a good idea to create a separate virtual environment for each Python application. Which provides an isolated environment where the Python project has its own modules and set of dependencies. To create Python virtual environment, run: All the files will be generated under /home/rahul/python-app/venv directory. You can active the environment by running command: Do your stuff with isolated environment here. Once you finish with your work, deactivate the environment by typing: This will return you back to the main system prompt.


This tutorial described you to install Python 3.9 on CentOS 8 and RHEL 8 systems using source code.