Python is a powerful programming language. It is very friendly and easy to learn. At the writing time of this article Python 3.8 latest stable version is available to download and install. This article will help you to install Python 3.8.12 on your CentOS, Red Hat & Fedora operating systems.
Step 1 – Install Required Packages
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 2 – Download Python 3.8
Download Python using following command from python official site. You can also download the latest version in place of the specified below.
cd /opt wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
Now extract the downloaded package.
tar xzf Python-3.8.12.tgz
Step 3 – Compile Python Source
Use below set of commands to compile python source code on your system using altinstall.
cd Python-3.8.12 sudo ./configure --enable-optimizations sudo make altinstall
Now remove downloaded source archive file from your system
sudo rm Python-3.8.12.tgz
Step 4 – Check Python Version
Check the latest version installed of python using the following command.
python3.8 -V Python 3.8.12
21 Comments
What if you can’t sudo? That is why I need a guide.
In Step 1, I would also include zlib-devel. Not doing so throws error in “make altinstall” or “make install” step.
Thanks Sundar, Article updated
Works great on Fedora 33, thanks 🙂
How to cleanly remove it the same way?
sudo make uninstall
uninstall is not a defined keyword from the Makefile
If you wanted to revert everything back after this installation, how would you do it?
Lo instale con root y todo funciona perfectamente pero tengo un problema, un usuario especifico no puede utilizar pip3.8, me recomiendas realizar la instalación con ese usuario utilizando sudo?
anexo el mensaje:
$ pip3.8 -V
Traceback (most recent call last):
File “/usr/local/bin/pip3.8”, line 6, in
from pip._internal.cli.main import main
ModuleNotFoundError: No module named ‘pip._internal’
Saludos y espero puedan ayudarme.
Followed your instructions, worked perfectly for Fedora 31. Thank you!
Please add: In case make command is not working use: yum install make
The version print typo still exists 🙂
Thanks Aditya, we have corrected the Typo.
Cheers
Please double check your tutorials 🙂
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz <—- 3.8 !!
tar xzf Python-3.4.8.tgz <—- 3.4 ??
python3.8 -V <—- 3.8 !!
Python 3.4.8 <—- 3.4 ??
Thanks Archi, I have corrected the typo.
you’ve used Python-3.4.8 by mistake in your text
Centos now supports Python-3.6.0 as well.
Better to use this version instead of the old 3.4
https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
cd /usr/src
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz -O Python-3.6.0.tgz
tar xzf Python-3.6.0.tgz
cd Python-3.6.0
###This enables some known optimizations in the higher versions os Python.
./configure –enable-optimizations
make altinstall
It seems to take forever, 10+ minutes now , message lines “checking” if, for variables listed alphabetically, and takes loops (?)
Thanks!
Please add the following step as well.
rm Python-3.4.3.tgz
Good Article. Small and to the point.