Python is a popular programming language. By default in CentOS 6/7 is used by default Python 2.7 version instead of widely used Python 3.8 which is the latest stable version now available to download and install at the date of this article.
We will instruct you how to install Python 3.8 on your CentOS 6/7, RHEL, Fedora versions.
1. Install prerequisites for Python before installing it.
# yum install gcc openssl-devel bzip2-devel libffi-devel
2. Downloading the archive
Download Python using following command from python official site. You can also download the latest version in place of specified below.
# cd /opt # wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
Now you may extract the downloaded Python 3.8.2 package.
# tar xzf Python-3.8.2.tgz
Use below set of commands to compile python source code on your system using ‘altinstall’.
4. Installing latest Python
# cd Python-3.8.2 # sudo ./configure --enable-optimizations # sudo make altinstall
When we use ‘make altinstall’ is will be preventing from the default python binary file replace in /usr/bin/python.
After completing installation you may remove downloaded source archive file from your system:
sudo rm Python-3.8.2.tgz
5. Checking Python version
Check the latest version installed of python using below command
# python3.8 -V