Python is an extremely popular, versatile, and easy-to-learn programming language that is widely used in various industries and applications, from web development and data analysis to artificial intelligence and machine learning. Python 3.9 is one of the latest versions of the language, offering improved performance and a host of new features.

Advertisement

In this tutorial, we will guide you through the process of installing Python 3.9 on CentOS/RHEL 7 and Fedora operating systems using the source archive file. This method of installation ensures that you have full control over the installation process and can customize it to suit your specific needs.

Prerequisites

This Python installation required the GCC compiler on your system. Login to your server using ssh or shell access. Now, use the following command to install prerequisites for Python before installing it.

sudo yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel 

Step 1 – Download Python 3.9

Download Python using following command from python official site. You can also download the latest version in place of the specified below.

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

Then, extract the archive file on your system:

tar xzf Python-3.9.16.tgz 

This will create a directory named Python-3.9.16 in the current directory.

Step 2 – Install Python 3.9 on CentOS

Change directory to Python-3.9.16 and use the following commands to compile Python source code on your system using altinstall.

cd Python-3.9.16 
sudo ./configure --enable-optimizations 
sudo make altinstall 
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

Now remove downloaded source archive file from your system

sudo rm Python-3.9.16.tgz 

Step 3 – Test Python Version

Check the latest version installed of python using the below command

python3.9 -V  

Python 3.9.16

Conclusion

In this tutorial, we demonstrated the step-by-step process of installing Python 3.9 on CentOS/RHEL 7 and Fedora systems using the source archive file. This method provides a more customizable installation experience and ensures that you have the latest Python version on your system. By following these steps, you can now enjoy the benefits of Python 3.9’s improved performance and new features, which will help you develop and deploy your projects more efficiently. As you continue to explore Python, consider familiarizing yourself with its vast ecosystem of libraries and frameworks to further enhance your programming capabilities.

Share.

3 Comments

  1. Roger Thompson on

    How do I do this in an alternate location without having sudo privilege? My location to install is /opt/python/Python-3.9.5

  2. Hi Rahul,

    Pretty straightforward. Worked like charm. Seems to be a better approach then adding epel or remi repo’s.
    If there is a new version, how should we deal with the old version – If for example 3.9.8 got release how do we get rid of this version?
    And.. how can I default to 3.9.4 (2.7.5 comes with a clean install)
    Regards

Leave A Reply


Exit mobile version