Python is most popular programming language. It’s used to write small scripts, build games, develop websites, create machine learning algorithms, analyze data and more. In this tutorial, we will show you how to install python 3.9 on CentOS 8 system.
Install Python 3.9 on CentOS 8
By default, Python 3.6 is included on CentOS 8. Currently, at the time of writing this article, Python 3.9 is the latest major release of Python. includes many new features such as new dict operators, new str functions, support for IANA time zone, and more. Python 3.9 is not available in the standard CentOS 8 repositories. On CentOS, you can install packages either with dnf
or yum
command.
Step 1: Install Python Dependencies
First, we need to install necessary packages to build Python from the source code on CentOS 8. Run the following commands as root or user with sudo privileges.
sudo dnf install wget yum-utils make gcc openssl-devel bzip2-devel libffi-devel zlib-devel
Step 2: Download Python 3.9
Download the latest release source code from the Python download page using wget command. Currently, the latest Python 3.9
release is 3.9.1
.
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
Extract the package using below command:
tar xvf Python-3.9.1.tgz
Navigate to the python source directory.
cd Python-3.9.1
Step 3: Install Python 3.9
Run the configuration
script to check all of the dependencies on your system are available:
sudo ./configure --enable-optimizations
Initiate compilation of Python 3.9 on CentOS 8.
sudo make altinstall
Note : Do not use the standard make install
otherwise it will overwrite the default system python binary.
That’s it. Python 3.9 has been installed on your CentOS system, and you can start using it.
Now, we don’t need
Step 4 – Verify Installation
Verify the installation by checking version:
python3.9 --version
The output should show the Python version:
Python 3.9.1
Pip is also installed, you can check version by typing:
pip3.9 -V
pip 20.2.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
Conclusion
I hope you successfully learned how to install Python 3.9 on your CentOS 8 system.
If you have any questions or feedback, please leave a comment below.