Install Python 3.12 on Rocky Linux 8 AlmaLinux 8

In this guide, you will learn to Install Python 3.12 on Rocky Linux 8 AlmaLinux 8, and RHEL 8. Python is one of the most popular programming languages that you can use to build websites and software. The latest stable version of this language at the current time is Python 3.12.

As you know, the default Python version available in RHEL 8 is not in the latest stable version. This tutorial intends to teach you how you can get the latest version of Python on RHEL 8 such as Rocky Linux 8 and AlmaLinux 8.

Quick Guide To Install Python 3.12 on Rocky Linux 8 AlmaLinux 8 RHEL 8

Before you start your Python 3.12 installation, be sure you have access to your server as a non-root user with sudo privileges. To get the AlmaLinux and Rocky Linux 8 initial guides, you can check the following articles:

Initial Server Setup with AlmaLinux 8

Initial Server Setup with Rocky Linux 8

Now proceed to the following steps to Install Python 3.12 on Rocky Linux 8 AlmaLinux 8, and RHEL 8.

Step 1 – Installing Dependencies For Python 3.12 on AlmaLinux 8 / Rocky Linux 8

At this point, you must install some required packages and dependencies for your Python 3.12 installation. To do this, run the system update and install them with the following commands:

# sudo dnf update -y
# sudo dnf install gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make tar -y

When you are done, you must download the latest packages from the official Python website.

Step 2 – Get the Latest Python Package on AlmaLinux 8 / Rocky Linux 8

Now you must visit the official downloads page and use the wget command to download the latest stable package:

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

Example Output:

Download Python 3.12 AlmaLinux and Rocky Linux 8

Then, extract your downloaded file with the following command:

sudo tar -xf Python-3.12.1.tgz

Step 3 – Configure and Install Python 3.12 on AlmaLinux 8 / Rocky Linux 8

At this step, you need to be sure that all dependencies work correctly for Python 3.12 installation. To do this, switch to your Python directory and run the following configuration script:

# cd Python-3.12.1
# sudo ./configure --enable-optimizations

Example Output:

Run configuration script for Python 3.12 installation

Then, find your system cores on your server with the command below:

sudo nproc
Example Output
2

Start Python 3.12 Build Process

Now that you have your system core number, you can use the following command to start your Python 3.12 build process. To do this, run the command below:

sudo make -j 2

This may take some time to complete depending on your system speed and network.

Example Output:

Start Python 3.12 Build Process

Install Python 3.12 on RHEL 8

Finally, you can use the following command to install the latest Python on AlmaLinux 8 and Rocky Linux 8:

sudo make altinstall

Example Output:

Install Python 3.12 on Rocky Linux 8, AlmaLinux 8, and RHEL 8

Check Python Version

When your installation is completed, verify it by checking the Python version:

python3.12 --version
Output
Python 3.12.1

Step 4 – Create a Test Project with Python 3.12

At this point, you have learned to Install Python 3.12 on Rocky Linux 8 AlmaLinux 8, and RHEL 8. We will show you how to create a test project with Python 3.12 to see if it is working correctly.

First, you need to create the Python project directory and switch to it with the following command:

# mkdir ~/test_app 
# cd ~/test_app

Then, from the project directory, create a virtual environment with the following command, we named it test_app_venv:

python3.12 -m venv test_app_venv

Next, activate your virtual environment with the command below:

source test_app_venv/bin/activate

You will see that your shell prompts changes to the name of your virtual environment.

For example, you can install Apache-Airflow inside your virtual environment with the pip package manager for Python:

pip install apache-airflow

This will install all the required packages and dependencies for your Apache-Airflow.

Note: If you face wheels for pendulum error, you must install a Pendulum version and Twitch IRC:

# pip install pendulum==2.0.3
# pip install python-twitch-irc

To exit from your virtual environment you can use the following command:

deactivate

Conclusion

At this point, you have learned to Install Python 3.12 on Rocky Linux 8 AlmaLinux 8, and RHEL 8. You just need to download the latest package from the official website and start to build and install your Python. Hope you enjoy it.

Also, you may interested in these articles:

Python 3.12 Installation on AlmaLinux 9 / RHEL 9

Install Python 3.12 on Ubuntu and Debian Server

Execute Shell Commands in Python with Examples

Run a Python Script in a Linux Docker Container

If you are looking for alternative languages to Python, you can read 5 Best Free Alternatives To Python.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!