This guide explains how to install Python 3.10 on CentOS 7 and CentOS 8 Linux systems. We have a similar guide for those users on Ubuntu and Debian-based systems such as LinuxMint among others.
Because the default CentOS repositories do not carry the latest version of Python we need to use the methods described below to install Python 3.10 on CentOS 7 or 8.
Step 1: Update Your CentOS 7 or CentOS 8 System
You need to be logged in as a non-root user with sudo privileges in order to follow along with this tutorial. Open the terminal and execute the following commands to update the installed packages.
$ sudo yum -y install epel-release
$ sudo yum -y update
Reboot the system after the completion of the updates:
$ sudo reboot
Step 2: Install Python Dependencies
Install required software development tools required to build the Python 3.10 source on CentOS 8 / CentOS 7:
$ sudo yum groupinstall "Development Tools" -y
$ sudo yum install openssl-devel libffi-devel bzip2-devel -y
Step 3: Download latest Python 3.10 Archive
At this point, if you do not have wget on your system then you can install it using this command
$ sudo yum install wget -y
Use wget to download Python 3.10 Archive:
wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz
Extract the archive file using tar:
$ sudo tar xvf Python-3.10.2.tgz
Switch to the directory created from the file extraction:
$ cd Python-3.10.2
Step 4: Configure and Install Python 3.10 on CentOS 7 and 8
Run this command to configure the build parameters:
$ ./configure --enable-optimizations
Now build the Python 3.10 source using this command:
$ sudo make altinstall
After a little while the build should complete successfully and can be confirmed using this command:
$ python3.10 --version
Python 3.10.2
Pip 3.10 will have been installed and you can run this command to confirm the pip installation:
$ pip3.10 --version
pip 22.0.2 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
Conclusion
That’s all there is to it. You now have the latest version of Python 3.10 on CentOS 7 | CentOS 8. Remember you can check the latest version of Python from the source release page.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.