In this article, we are going to teach you How to Configure Python on Rocky Linux 8. Computer programming is the foundation of the digital age in which we live today. Every time that you like to post on social media, send an email or set a clock on your phone, a programming language works behind the scenes. Python is one of the programming languages. You can also buy Linux VPS server from NeuronVM and run Rocky Linux operating system on it.
Introduction to Python
Python is a powerful, high-level, object-oriented, professional programming language developed and published by Guido van Rossum in 1991. Python runs on various operating systems such as Windows, Mac, Linux, Raspberry Pi and etc. It should note that Python has a syntax that allows developers to write applications with less coding than other programming languages. Python runs on a translator system, meaning it can be run as soon as code is written.
– Simple reading and coding
– Easy to learn
– Existence of a strong community and excellent prototypes
– Being scalable
– A forward language
– Has many frameworks
Prerequisites to Configure Python on Rocky Linux
1- Rocky Linux 8
2- Setup a non-root user with a sudo privilege on your Rocky system
How to Install Python on Rocky Linux 8
First of all, you need to update the system software packages:
sudo dnf -y update
Note that the default Rocky Linux 8 AppStream repository has Python. You can install the latest version of Python by executing the following command:
sudo dnf install python3.9
Now you should type “Y” and then press Enter. This will start the installation process.
Next, you should run the following command to verify the Python version:
The installation of Python on your Rocky Linux system is completed.
Also, you can install Python manually using the Python 3.9 archive. To do this first, open your Terminal and enter the following command. This will install the packages needed to compile Python packages on Rocky Linux 8.
sudo dnf groupinstall "Development Tools" -y
Next, you should install the necessary dependencies such as openssl-devel, libffi-devel. To do this, run the following command:
sudo dnf install openssl-devel libffi-devel bzip2-devel -y
Install wget on your server using the following command:
sudo dnf install wget -y
Now you can download the Python by executing the following command. Then you should extract the zip file and go to the extracted directory:
wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tar.xz tar xvf Python-3.9.7.tar.xz cd Pyhton-3.9.7
Configuring Python on Rocky Linux 8
In this step, configure the source code by entering the following command:
Then run the following command to install the Python packages:
sudo make altinstall
Altinstall is using to make install because the latter overwrites all existing Python binary. Python 3.9 is required to coexist on the same system with any other version of Python installed. Otherwise, multiple versions cannot be used simultaneously.
Completing the above command may take a long time. When the Python installation is complete, you will receive the following message:
You can use the following command to verify your Python version:
After installing Python and all its dependencies, you can install your desired modules for Python. The requests module will be installed by entering the following command:
python3.9 -m pip install <module>
Remember to enter the name of your desired module instead of <module>.
You can see the modules installed on your server with the help of the following command:
python3.9 -m pip list
How to Test the Python Installation on Rocky Linux 8
First, you need to create a test file with your favorite text editor such as vi or nano. To do this, run the following command:
sudo nano hello.py
Now you need to copy the following code and paste it into your file:
Then save the changes and exit.
Next, you should run the program by entering the following command:
If there is no problem, finally you will get the following message.
Python can be used for many purposes; this means that you can both design a site and write software with Python. This article taught you how to configure Python on Rocky Linux 8. I hope this tutorial was helpful for you.