In this article, we want to teach you How To Set up Python 3.10 on Centos 7.
Python is a popular general-purpose programming language that can be used for a wide variety of applications.
It includes high-level data structures, dynamic typing, dynamic binding, and many more features that make it as useful for complex application development as it is for scripting or “glue code” that connects components together.
Also, it can be extended to make system calls to almost all operating systems and to run code written in C or C++.
Due to its ubiquity and ability to run on nearly every system architecture, Python is a universal language found in a variety of different applications.
Steps To Set up Python 3.10 on Centos 7
Currently, the latest stable version of Python is 3.10.2. In this guide, you will learn to install Python 3.10.2 on Centos 7.
First, 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 Centos 7.
Now follow the steps below to install Python 3.10 on Centos 7.
Install Python 3.10 on Centos 7
First, you need to update your local package index with the command below:
sudo yum update -y
Install Python Dependencies
Then, use the following command to install the required packages on Centos 7:
# sudo yum groupinstall "Development Tools" -y # sudo yum install wget openssl-devel libffi-devel bzip2-devel -y
Download Python 3.10
Now use the wget command to download Python 3.10.2 from the Python Releases page.
Extract your downloaded file with the following command:
tar xvf Python-3.10.2.tgz
Next, switch to your Python 3.10 directory:
Build and Install Python 3.10
To set up Python installation on Centos 7, run the command below:
After that, use the following command to build Python 3.10 on Centos 7:
sudo make altinstall
This will take some time to complete.
Verify Python and pip 3.10 Installation on Centos 7
When you are done, you can verify your Python installation on Centos 7 by checking its version:
Output Python 3.10.2
Also, pip 3.10 must be installed on your server. To check it run the following command:
Output pip 21.2.4 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
Here you can test your Python 3.10 that is working correctly on your Centos 7.
Access Python shell on Centos 7
At this point, you can access your Python shell with the command below:
Create a Test Program
Now you can write a simple program to find the sum of two variables, x, and y to test your program:
x = 35 y = 75 z = x + y print("Hello, the sum of x and y is", +z)
In your output you will see:
Hello, the sum of x and y is 110
At this point, you learn to Set up Python 3.10 on Centos 7.
Hope you enjoy it.
May you will be interested in these articles:
How To Set up Python 3.10 on AlmaLinux 8.