This is an update to a guide we released on how to install Python 3.10 on CentOS. This time around we will show you how to install Python 3.11 on CentOS 7 and CentOS 8 Linux Systems.
This tutorial is for those who want the latest and greatest Python version seeing the default CentOS repositories do not carry the latest version of Python. So let’s get started.
Step 1: Update Your CentOS 7 or CentOS 8 System
While logged in as anon-root user with sudo privileges, open the terminal and execute the following commands to update the installed packages.
$ sudo yum -y install epel-release
$ sudo yum -y update
Step 2: Install Python Dependencies
With our system up-to-date we can go ahead and install the software development dependencies required to build the Python 3.11 source code on CentOS 8 or CentOS 7:
$ sudo yum groupinstall "Development Tools" -y
$ sudo yum install openssl-devel libffi-devel bzip2-devel -y
Step 3: Download latest Python 3.11 Source Archive
We will be using wget to download the archive. In case you do not have it on your system you can run this command to get it installed:
$ sudo yum install wget -y
Now we can use wget to download Python 3.11 Archive:
$ wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz
We will be using Python 3.11.1 in this tutorial but the steps should be the same for updated versions.
Extract the archive file using tar:
$ sudo tar xvf Python-3.11.1.tgz
Now, switch to the directory created from the file extraction:
$ cd Python-3.11.1
Step 4: Configure and Install Python 3.11 on CentOS 7 or 8
Run this command to configure the build parameters:
$ ./configure --enable-optimizations
You can now build the Python 3.11 source using this command:
$ sudo make altinstall
Once all the activity is complete successfully you can confirm the install using this command:
$ python3.11 --version
Python 3.11.1
Bonus: Pip 3.11 will also be installed and you can run this command to confirm the pip installation:
$ pip3.11 --version
pip 22.3.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
In Closing
You now have the latest version of Python 3.11 on CentOS 7 and CentOS 8. Remember if you follow the above tutorial be sure to substitute the commands using 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.