Skip to content

How to Install Python 3.10 on CentOS/RHEL 9/8 & Fedora

Steps
4
Category
Python
Covers
CentOS, Fedora, RHEL
On this page 4 steps

The Python development team has released the latest version of Python 3.10. This includes more new features, security patches, and many other improvements. This version includes a new feature that is Parenthesized, context managers. Using enclosing parentheses for continuation across multiple lines in context managers is now supported. For more details read the complete changelog.

This tutorial will help you with the installation of Python 3.10 on all Fedora versions and CentOS/RHEL 8 Linux systems. The tutorial will compile and install Python 3.10 source code on your system.

Prerequisites

The system must have a pre-installed GCC compiler on your system. In order to install all required packages, Login to your server using ssh or shell access, and execute the following command to install all prerequisites for Python.

sudo dnf install wget yum-utils make gcc openssl-devel bzip2-devel libffi-devel zlib-devel 

Step 1 of 4Download Python 3.10 Source Code

The first step is to download the Python 3.10 source code. Visit the official download site https://www.python.org/ftp/python to download the latest or required version of the Python.

Command line users can download Python 3.10 via the command line:

wget https://www.python.org/ftp/python/3.10.16/Python-3.10.16.tgz 

Then, extract the archive file from your system

tar xzf Python-3.10.16.tgz 

This will create a directory named Python-3.10.16 in the current directory containing all source files for Python 3.10.

Step 2 of 4Installing Python 3.10 on Fedora/CentOS

Change the directory to Python-3.10.8. Then prepare the source code with the required values before compiling it.

cd Python-3.10.16 
sudo ./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions 

Next, compile the source code with make. Here nproc will provide the number of CPU cores available on system. So that make can perform well.

sudo make -j ${nproc} 
sudo make altinstall 
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

Now, we don’t need the downloaded archive file, so delete it to free space.

sudo rm Python-3.10.16.tgz 

Step 3 of 4Test Python Version

At this step, you have successfully installed Python 3.10 on Fedora or CentOS/RHEL system. Now, check the installed versions of Python and PIP.

Check Python Version:

python3.10 -V  

Python 3.10.16

Check PIP Version:

pip3.10 -V  

pip 20.2.3 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)

Step 4 of 4Create Virtual Environment

It is a good idea to create a separate virtual environment for each Python application. Which provides an isolated environment where the Python project has its own modules and set of dependencies.

To create Python virtual environment, run:

cd ~/python-app/ 
sudo /usr/local/bin/python3.10 -m venv appenv 

Here ~/python-app is containing the Python application. All the env files will be generated under ~/python-app/appenv directory. You can active the environment by running command:

source appenv/bin/activate 

Do your stuff in an isolated environment here. Once you finish with your work, deactivate the environment by typing:

deactivate 

This will return you back to the main system prompt.

Conclusion

This tutorial described you to install Python 3.10 on Fedora and CentOS/RHEL 8 systems using the source code.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

4 Comments

  1. Hi, I am getting this error after install:

    WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top