How to Run Python 2.7 on AlmaLinux 9
This is the most user-friendly guide that will walk you through the steps of How to Run Python 2.7 on AlmaLinux 9.0; we will provide a step-by-step guide to achieve this goal. We knew it could be challenging to run Python on AlmaLinux, but this article will break it down for you to help you achieve your goal as easily as possible.
Some software still depends on this version of Python, so it is necessary to learn how to install Python 2.7 on AlmaLinux, there are also other uses for this version such as testing and educational purposes.
What is the way to Run Python 2.7 on AlmaLinux 9?
We will guide you through the steps to running Python on AlmaLinux, so read till the end! AlmaLinux 9 is now available, visit their website to download it now.
Update System
We want to have a fresh start when installing Python 2.7 on our system, open your Terminal and enter the following command to update all of your packages.
sudo dnf update -y
Requirements for installation
Before installing Python, we need to install several libraries and tools that Python depends on; these include libraries for SSL and other functionalities, run the following command to install prerequisites:
sudo dnf install openssl-devel bzip2-devel libffi-devel zlib-devel wget yum-utils make gcc tar
After installing the prerequisites, it is better to update your system and be sure all of your packages are installed and also updated. Run the following command.
sudo dnf update -y
Download Python
Python 2.7 is not the latest version of Python; you can always get the latest version by replacing the following command, but run the following command to Download Python 2.7 on your system.
cd /root wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
Extract file
Once the source code was downloaded, we needed to extract the downloaded file; we can extract it using the tar command and run the following command to extract the contents of the downloaded file.
tar xzf Python-2.7.18.tgz
Python Installation Folder
Once you have extracted your file, you need to navigate to the directory where the Python source code is, by running the following command, you will change the current directory to Python 2.7.18.
cd Python-2.7.18
Configure Installation
It is better to configure the built environment before compiling the Python source code, run the following command to configure the Python installation:
./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions
You will see an output similar to this after running the previous command.
configure: creating Modules/Setup.local configure: creating Makefile configure:
Compile
Run the following command to compile the code:
make -j ${nproc}
Install Python
With the following command, you will avoid overwriting the default Python, if you are using other versions of Python it is better to use the provided command to keep them intact.
make altinstall
Shortcut
After installing Python, you might notice that the Python Terminal is not working, this is because the system does not know where to find the installed Python version, to fix this issue run the following command.
ln -s /usr/local/bin/python2.7 /usr/bin/python2
Check Installation
After setting the shortcut, make sure everything is working well.
python2.7 -V
If the output of this command shows you the exact version of the Python we have installed, then it shows that we have successfully installed it.
Conclusion
Congratulations on successfully installing Pythom 2.7 ib AlmaLinux 9.0. by following the provided step-by-step guide. While Python 2.7 is not officially supported, it still has some critical usages, but feel free to replace the outlined commands with the version of Python you want to install on AlmaLinux. If you come across any problems during the installation leave us a comment so our tech team will reach you to help you solve your problem as quickly as possible.