If you do not already know, Python is a high-level programming language that supports multiple programming schemes, including object-oriented, functional, and structured programming.
The usage of the Python programming language is increasing on a daily basis, and the number of applications written in Python has been extremely large in past years. One of the most popular apps that are written in Python are Dropbox, Spotify, Odoo, Pinterest, Uber, and so on.
In this tutorial, we are going to show you how to install Python on AlmaLinux 9 OS.. Let’s get started! You will need the following:
- A server with AlmaLinux 9 as OS
- User privileges: root or non-root user with sudo privileges
Table of Contents
Step 1. Update the System
Every fresh installation of AlmaLinux, needs the packages to be updated to their latest versions available. To do that, execute the following command:
sudo dnf update -y && sudo dnf upgrade -y
Step 2. Install Python Prerequisites
Before we proceed with Python installation, we need to install some prerequisites. To install the prerequisites execute the following command:
dnf install openssl-devel bzip2-devel libffi-devel zlib-devel wget yum-utils make gcc tar -y
Once the prerequisites are installed, update the system again.
sudo dnf update -y
Step 3. Download and Install Python
We need to download the source code of the latest Python 3.12.0 version. Execute the following command:
cd /root wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0a1.tgz
Once downloaded, you should receive the following output:
[root@host ~]# wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0a1.tgz --2023-06-02 09:02:01-- https://www.python.org/ftp/python/3.12.0/Python-3.12.0a1.tgz Resolving www.python.org (www.python.org)... 199.232.28.223, 2a04:4e42:44::223 Connecting to www.python.org (www.python.org)|199.232.28.223|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 26396588 (25M) [application/octet-stream] Saving to: ‘Python-3.12.0a1.tgz’ Python-3.12.0a1.tgz 100%[=====================================================================================>] 25.17M 5.67MB/s in 4.5s 2023-06-02 09:02:06 (5.65 MB/s) - ‘Python-3.12.0a1.tgz’ saved [26396588/26396588]
Now, we need to extract the downloaded file with the following command:
tar xzf Python-3.12.0a1.tgz
Once extracted, enter into the Python installation folder and execute the following commands:
cd Python-3.12.0a1 ./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions
This will prepare the Python installation and will configure it before compiling. Once done, you should get the following output:
configure: creating Modules/Setup.local configure: creating Makefile configure: If you want a release build with all stable optimizations active (PGO, etc), please run ./configure --enable-optimizations
Next, we need to compile the code and install Python with the following commands:
make -j ${nproc} make altinstall
After the installation, you will receive the following output:
/usr/bin/install -c -m 755 Modules/xxlimited_35.cpython-312-x86_64-linux-gnu.so /usr/local/lib/python3.12/lib-dynload/xxlimited_35.cpython-312-x86_64-linux-gnu.so /usr/bin/install -c -m 644 ./Misc/python.man \ /usr/local/share/man/man1/python3.12.1 if test "xupgrade" != "xno" ; then \ case upgrade in \ upgrade) ensurepip="--altinstall --upgrade" ;; \ install|*) ensurepip="--altinstall" ;; \ esac; \ ./python -E -m ensurepip \ $ensurepip --root=/ ; \ fi Looking in links: /tmp/tmp1hx29q38 Processing /tmp/tmp1hx29q38/setuptools-65.5.0-py3-none-any.whl Processing /tmp/tmp1hx29q38/pip-22.3-py3-none-any.whl Installing collected packages: setuptools, pip Successfully installed pip-22.3 setuptools-65.5.0
Now, we need to create a symbolic link from the current Python folder.
ln -s /root/Python-3.12.0a1/python /usr/bin/python3
Once the symbolic link is created, you can check the installed version:
python3 -V
You should get the following output:
[root@host ~]# python3 -V Python 3.12.0a1
That’s it. You successfully installed the latest Python 3.12 version on AlmaLinux 9 OS. Now, you can start to use it in your applications. Of course, you do not have to do this setup on your own if you find it difficult. You can always contact our technical support and they will help you with any aspect of installation and configuration. All you need to do is to sign up for one of our Linux VPS plans and submit a support ticket. We are available 24/7.
If you liked this about installing Python on AlmaLinux 9, please share it with your friends on social networks using the buttons on the left or simply leave a reply below.
Eay to follow and simple to understand, great effort
It works for me!
many tanks!