Python is a friendly, powerful and easy to learn programming language. At the writing time of this article Python 3.8 latest stable version is available to download and install.
The default yum repositories provides Python 3.6 packages to install on CentOS 8 systems. So this article will help you to install Python 3.7 by compiling source code on CentOS 8 and RHEL 8 Linux systems.
Prerequisites
Login to your CentOS 8 system with root or sudo privileged account. Desktop users open a terminal on your system.
Then use the following command to install required development libraries for Python before installing it.
sudo dnf install gcc openssl-devel bzip2-devel libffi-devel
Download Python 3.7 Archive
You can download Python using following command from its official site. We also recommend to visit python ftp directory to check for latest version. To download Python 3.7.9, use the following commands.
cd /opt wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
Then, extract the downloaded archive on your system.
tar xzf Python-3.7.9.tgz
Install Python 3.7 on CentOS 8
After extracting the archive file, switch to the extracted directory. Then configure the source files based on your system environment. After that use following commands to compile python source code on your system using altinstall
.
cd Python-3.7.9 sudo ./configure --enable-optimizations sudo make altinstall
Now remove downloaded source archive file from your system
sudo rm Python-3.7.9.tgz
Test Python Version
Using the above installation, Python creates a separate binary file on your system. To use Python 3.8, you need to use the specific binary file. To test the Python 3.7, execute:
python3.7 -V Python 3.7.9
Conclusion
In this tutorial, you have learned to install Python 3.7 on CentOS 8 from source code.
6 Comments
i do all steps but still have python3 -V give 3.6
How to UnInstall?
You also need “make” in your dnf install command.
Prerequisites:
where is make command?
sudo yum install make
I installed Python 3.7.7 successfully. Can I use the old pip with Python 3.7.7, or I must use pip3 (or something like pi3-7) and how to install it?