Rocky Linux 8 is a popular open-source operating system that is heavily used for server management, data analysis, and web development. One of the key benefits of using Rocky Linux 8 is its compatibility with various programming languages, including Python. Python is a versatile programming language that is widely used for creating web applications, performing data analysis, and developing machine learning models. In this article, we will walk you through the steps to configure Python on Rocky Linux 8 so you can start developing Python applications with ease.
Prerequisites
1- A Linux VPS with Rocky Linux 8 operating system
2- Setup a non-root user with a sudo privilege on your Rocky system
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:
python3.9 --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
In this step, configure the source code by entering the following command:
./configure --enable-optimizations
Then run the following command to install the Python packages:
sudo make altinstall
Altinstall is used 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:
python3.9 --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
Output:
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:
cd Python-3.9.7
sudo nano hello.py
Now you need to copy the following code and paste it into your file:
print("NeuronVM, HelloWorld!")
Then save the changes and exit.
Next, you should run the program by entering the following command:
python3.9 hello.py
If there is no problem, finally you will get the following message.
NeuronVM, HelloWorld!
Configuring Python on Rocky Linux 8 is a straightforward process that enables you to start developing Python applications quickly and efficiently. By following the steps outlined in this guide, you can install Python, set up a virtual environment, and begin installing Python packages to kickstart your development projects. Whether you are a beginner or an experienced developer, having Python configured on your Rocky Linux 8 system will open up a world of possibilities for your programming journey. If you are interested in installing Python on other Linux distributions including Debian, we suggest you read the article The Ultimate Guide to Install Python on Debian 11.
How useful was this post?
Click on a star to rate it!
Average rating 5 / 5. Vote count: 2
No votes so far! Be the first to rate this post.
DirectAdmin helps you manage your web server and website easily. Also, this control panel manages fi...
Each Desktop is a graphical user interface, with its own shape and icon, such as how icons, windows,...
What is your opinion about this Blog?