How to Install Python on CentOS 8

Install Python on CentOS 8

In this article, we will have explained the necessary steps to install and configure Python on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Python is one of the most widely used programming languages in the world. Python is a quite versatile programming language, you can use it to do almost anything you want, write small scripts, build games, develop websites, create machine learning algorithms, analyze data and more.

Install Python on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf update

Step 2. Install Python on CentOS 8.

The first thing to do is to install the packages necessary to build Python from the source code on CentOS:

sudo dnf groupinstall 'development tools'
sudo dnf install bzip2-devel expat-devel gdbm-devel \
    ncurses-devel openssl-devel readline-devel \
    sqlite-devel tk-devel xz-devel zlib-devel wget

Next, download Python using the following command from the Python official site:

wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
tar xzf Python-3.8.1.tgz

Then, enter into the new directory that was just created and compile Python source code on your system using altinstall:

cd Python-3.8.1
./configure --enable-optimizations
make altinstall

That’s it. Python 3.8 has been installed on your CentOS system, and you can start using it. Verify it by typing:

python3.8 --version

Congratulation, you have learned how to install and configure Python on CentOS 8. If you have any question, please leave a comment below.