Install Python 3.11 on AlmaLinux 9 with Efficient Steps
In this guide, we intend to teach you How To Install Python 3.11 on AlmaLinux 9. Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems. This versatility, along with its beginner-friendliness, has made it one of the most-used programming languages today.
At the current time, the latest stable release of Python is 3.11 which you will learn to Install Python 3.11 on AlmaLinux 9 in this guide from the Orcacore website.
To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.
Set up Python 3.11 on AlmaLinux 9
First, you need to update your local package index with the following command:
sudo dnf update -y
Install Dependencies for Python 3.11
Then, install the required packages and dependencies on your server with the command below:
sudo dnf install gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make tar -y
Download Python 3.11
Now you need to visit the Python Downloads page to check the latest stable version and download it with the following wget command:
sudo wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz
Extract your downloaded file with the following command:
sudo tar -xf Python-3.11.1.tgz
Next, switch to your source directory:
cd Python-3.11.1
Run Configuration Script
At this point, you need to run the configuration script to be sure that all dependencies are ready for the Python 3.11 installation to work on AlmaLinux 9:
./configure --enable-optimizations
–enable-optimizations option is for use after all debugging and maximum performance with minimum run-time checks is required.
Build and Install Python 3.11 AlmaLinux 9
After the configuration script is completed, you need to start your build process with the following command:
make -j 2
The -j option is related to the number of cores in your system to speed up the build time.
To find how many cores you have on your system, you can use the following command:
nproc
The build process takes some time to complete.
When it is finished, you can install the Python 3.11 source on AlmaLinux 9 with the following command:
sudo make altinstall
When your installation is completed, you can verify your Install Python 3.11 on AlmaLinux 9 by checking its version:
python3.11 --version

To ensure that Python 3.11 is working correctly, you can create a test Python project.
Test Python 3.11 AlmaLinux 9
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, here we named it test_app_venv:
python3.11 -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
To exit from your virtual environment you can use the following command:
deactivate
Conclusion
At this point, you learn to Install Python 3.11 on AlmaLinux 9 and create a test Python project. You can stay tuned for the latest Python releases setup on AlmaLinux 9.
I hope you enjoy it. You may also like these articles:
How To Install Docker on Rocky Linux 9
Reset Root Password on Rocky Linux 9
Install PowerDNS on AlmaLinux 9
Alternative Solutions for Installing Python 3.11 on AlmaLinux 9
While the method outlined above, compiling from source, provides a direct and customizable approach to installing Python 3.11 on AlmaLinux 9, there are alternative methods that can be more convenient and efficient, especially for users who prefer not to manage dependencies and build processes manually. Here are two such alternative solutions:
1. Using a Package Manager (IUS Community Project)
The Independent Utilities and Software (IUS) project provides newer versions of software packages for Enterprise Linux distributions like AlmaLinux. This approach leverages the system’s package manager, dnf
, which simplifies the installation and management of dependencies.
Explanation:
IUS offers pre-built packages of Python 3.11. By enabling the IUS repository, you can install Python 3.11 using dnf
, which automatically resolves and installs all necessary dependencies. This eliminates the need to manually download, configure, and build from source. It also makes updating Python in the future easier, as you can simply use dnf update
.
Steps:
-
Install the IUS Release Package: This package configures your system to use the IUS repository.
sudo dnf install https://repo.ius.io/ius-release-el9.rpm -y
-
Enable the IUS Module (if needed): AlmaLinux uses modules to manage different versions of software. You might need to explicitly enable the Python 3.11 module.
sudo dnf module enable python39:ius #this enables IUS for python 3.9, may need to adjust if IUS has a module for 3.11. if python39:ius doesn't exist, try looking for available IUS modules with dnf module list
-
Install Python 3.11: Use
dnf
to install thepython3.11
package from the IUS repository. You’ll likely also want the development package.sudo dnf install python3.11 python3.11-devel -y
-
Verify the Installation: Check the Python version to confirm the installation.
python3.11 --version
Advantages:
- Simpler installation process.
- Automatic dependency resolution.
- Easier updates through
dnf
.
Disadvantages:
- Relies on a third-party repository (IUS). While IUS is generally reliable, it’s important to trust the source.
- Potentially less control over specific build options compared to compiling from source.
2. Using a Conda Environment
Conda is an open-source package, dependency, and environment management system. It’s primarily used for Python but can also manage other software. Using Conda allows you to create isolated environments with specific Python versions and dependencies, without affecting the system’s default Python installation.
Explanation:
Conda allows you to create a virtual environment with Python 3.11. This environment is self-contained and doesn’t interfere with the system’s Python installation or other Conda environments. This approach is particularly useful for managing multiple Python projects with different version requirements.
Steps:
-
Download and Install Miniconda (or Anaconda): Miniconda is a minimal version of Anaconda that includes only Conda, Python, and their dependencies. Anaconda includes a large number of pre-installed packages. Download the appropriate installer for Linux from the Anaconda website (or Miniconda website).
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh # Or the Anaconda equivalent
-
Run the Installer: Make the script executable and run it.
chmod +x Miniconda3-latest-Linux-x86_64.sh ./Miniconda3-latest-Linux-x86_64.sh
Follow the prompts in the installer. When prompted, choose a location for the Conda installation. It’s generally recommended to accept the default location. After installation, initialize Conda with:
conda init bash
Close and reopen your terminal or source your
~/.bashrc
file to activate the Conda base environment. -
Create a Conda Environment with Python 3.11: Use the
conda create
command to create a new environment with Python 3.11.conda create --name python311env python=3.11
-
Activate the Environment: Activate the newly created environment.
conda activate python311env
Your shell prompt will change to indicate that the environment is active.
-
Verify the Installation: Check the Python version within the environment.
python --version
It should show Python 3.11.x.
Code Example: Using Conda to manage packages
Once the environment is activated, you can install packages using conda install
or pip install
. For example:
conda install numpy
or
pip install requests
Deactivating the Environment:
When you’re finished working in the environment, you can deactivate it:
conda deactivate
Advantages:
- Isolated environments prevent conflicts between different projects.
- Easy management of dependencies using
conda install
orpip install
. - Supports multiple Python versions on the same system.
- Reproducible environments for consistent results.
Disadvantages:
- Requires installing Conda, which can be a relatively large installation.
- Can consume more disk space due to the creation of multiple environments.
- Requires learning Conda commands.
These alternative methods provide easier and more convenient ways to Install Python 3.11 on AlmaLinux 9 compared to building from source. Choosing the right method depends on your specific needs and preferences. If you want a system-wide installation with automatic dependency resolution, IUS is a good option. If you need isolated environments for different projects, Conda is a better choice. Both options allow you to harness the power of Python 3.11 on your AlmaLinux 9 system without the complexities of manual compilation.