Python 3.11 is recently launched with multiple improvements and security upgrades. This version provides developers to easily debug their code with fine-grained error locations in tracebacks. The new “Self” annotation provides a simple way to annotate methods that return an instance of their class.
Mostly the latest operating systems come with the latest Python versions. But the OS versions released before the release of Python 3.11 may not have the latest version. This tutorial will help you to install Python 3.11 on your CentOS, Red Hat & Fedora operating systems by compiling it from source code.
This Python installation required a 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.
sudo dnf install gcc openssl-devel bzip2-devel sqlite-devel
Step 1: Download Python 3.11
Download Python using the following command from the Python official site. You can also download the latest version in place of specified below.
Now extract the downloaded package.
tar xzf Python-3.11.3.tgz
Step 2: Install Python 3.11 on CentOS & Fedora
Use the below set of commands to compile Python source code using the ./configure script and the make with altinstall.
sudo ./configure --enable-optimizations
sudo make altinstall
make altinstall is used to prevent replacing the default python binary file
Now remove the downloaded source archive file from your system
sudo rm /usr/src/Python-3.11.3.tgz
Step 3: Check Python Version
Check the latest version installed of python using the below command.
python3.11 -VPython 3.11.3
In this tutorial, you have found the instructions to install Python 3.11 on CentOS, RHEL, and Fedora systems by compiling it from the source code. We still suggest to the package manager for the Python installation, but if the package manager is failing to do it, compile it from the source code.