How to Install Python 3.12 on AlmaLinux 8

Python 3.12 is the newest major release of the Python programming language, and it contains many new features and optimizations.

Update Package Index

First, ensure your system is up-to-date by running,

dnf update

Install Dependencies

Install necessary packages to build Python from source,

dnf install gcc openssl-devel bzip2-devel libffi-devel wget tar make

Download Python 3.12 Source Code

Visit the Python downloads page to get the source code. Then, using wget, download the source,

cd /tmp

Now, Extract the Archive,

tar -xf Python-3.12.0.tgz

Configure and Compile Python

cd Python-3.12.0
./configure --enable-optimizations
make -j $(nproc)
sudo make altinstall

Verify Installation

Check if Python 3.12 has been installed successfully,

python3.12 --version


[root@vps Python-3.12.0]# python3.12 --version
Python 3.12.0
[root@vps Python-3.12.0]#

And that's it! You may now use Python 3.12 to develop software, build web apps, establish workflows, and more.