How To Set up Python 3.10 on AlmaLinux 8

In this article, we want to teach you How To Set up Python 3.10 on AlmaLinux 8.

Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high-level dynamic data types, and classes.

Currently, the latest stable release of Python is 3.10.2. In this guide, you will learn to install Python 3.10.2 and create a test application on AlmaLinux 8.

How To Set up Python 3.10 on AlmaLinux 8

Before you start to complete this guide, you need to log in to your server as a root or non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with AlmaLinux 8.

Now follow the steps below to install Python 3.10 on AlmaLinux 8.

Install Python 3.10 on AlmaLinux 8

First, you need to update your local package index with the following command:

sudo dnf update -y

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 -y

Now you need to visit the Python Downloads page to check the latest stable version and download it with the following command:

sudo wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz

Extract your downloaded file with the following command:

tar -xf Python-3.10.2.tar.xz

Next, switch to your source directory:

cd Python-3.10.2

At this point, you need to run the configuration script to be sure that all dependencies are ready for the Python 3.10 installation to work on AlmaLinux 8:

./configure --enable-optimizations

–enable-optimizations option is for use after all debugging has taken place and maximum performance with minimum run-time checks is required.

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 Python 3.10 source on AlmaLinux 8 with the following command:

sudo make altinstall

When your installation is completed, you can verify your Python 3.10 installation on AlmaLinux 8 by checking its version:

python3.10 --version
Output
Python 3.10.2

Now to be sure that Python 3.10 is working correctly on AlmaLinux 8, you can create a test Python project.

Create a Test Python project on AlmaLinux 8

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.10 -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 prompt 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 Set up Python 3.10 on AlmaLinux 8 and create a test Python project.

May this article about How To Install Python 3.10 on Debian 11 be useful for you.

Hope you enjoy it.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!