How to install Python3.9 on CentOS

This post describes how to install Python3.9 on CentOS along with the older versions of Python3. In this example we will install Python3.9 on the CentOS server which is having Python3.6 installed. By following below steps Python3.9 would be installed on the server without impacting existing installation.

Check current Python installations on CentOS server
            
which python
# Output
/usr/bin/python   

python --version
# Output
Python 2.7.5

which python3
# Output
/usr/bin/python3

python3 --version
# Output
Python 3.6.8
        
        

Python3.9 installation steps:

Step 1: Download the Python Gzipped source file

         

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


Step 2: Unpack the .tgz file

        

tar zxvf Python-3.9.7.tgz

    
    

Step 3: Navigate to Python-3.9.7 folder

        

cd Python-3.9.7/

    
    

Step 3: Execute configure script

        

./configure

    
    

Step 3: Build the Python3.9 binary

    

make


Step 4: Install the Python3.9 binary

        

sudo make altinstall

    
    

Step 5: Verify Python3.9 and previous installations

    

which python3.9
# Output
/usr/local/bin/python3.9

python3.9 --version
# Output
Python 3.9.7

which python3
# Output
/usr/bin/python3

python3 --version
# Output
Python 3.6.8

which python
# Output
/usr/bin/python

python --version
# Output
Python 2.7.5

Categories: Python