You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

In today’s guide you’ll learn to install Python 3.9 on CentOS 8 / CentOS 7 Linux system. Python is general-purpose, interpreted and high-level programming language originally created by Guido van Rossum. Python is created for simplicity, deep integration and great extensibility. You can achieve much more with Python using powerful libraries and tools, including Django, Pygame, Matplotlib, Plotly, e.t.c.

In the next sections we look at the installation steps of Python 3.9 on CentOS 8 / CentOS 7. If you’re interested in a full list of features shipped in Python 3.9 check the official release notes.

Install Python 3.9 on CentOS 8 / CentOS 7

Python is a cross-platform software package meaning it can run on Linux, Windows, macOS, and BSD systems. As of this article update, the exact latest release of Python 3.9 is version Python 3.9.1. This is the version of Python that will be installed in this tutorial.

Step 1: Install Python Dependencies

Login to your CentOS 8 / CentOS 7 system as root or user with sudo privileges.

$ ssh [email protected]

Then do system update

sudo yum -y update

Install required software development tools required to build Python 3.9 on CentOS 8 / CentOS 7:

sudo yum groupinstall "Development Tools" -y
sudo yum install openssl-devel libffi-devel bzip2-devel -y

Confirm gcc is available:

$ gcc --version
gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Step 2: Download latest Python 3.9 Archive

Ensure wget is installed:

sudo yum install wget -y

Use wget to download the latest Python 3.9 release.

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

Extract the archive file using tar:

tar xvf Python-3.9.2.tgz

Switch to the directory created from the file extraction:

cd Python-3.9*/

Step 2: Install Python 3.9 on CentOS 8 / CentOS 7

Run the command below to configure Python installation.

./configure --enable-optimizations

Sample output of success:

....
checking for the Linux getrandom() syscall... yes
checking for the getrandom() function... yes
checking for library containing shm_open... -lrt
checking for sys/mman.h... (cached) yes
checking for shm_open... yes
checking for shm_unlink... yes
checking for pkg-config... /usr/bin/pkg-config
checking whether compiling and linking against OpenSSL works... yes
checking for X509_VERIFY_PARAM_set1_host in libssl... yes
checking for --with-ssl-default-suites... python
checking for --with-builtin-hashlib-hashes... md5,sha1,sha256,sha512,sha3,blake2
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
creating Modules/Setup.local
creating Makefile

Build Python 3.9 on CentOS 8 / CentOS 7:

sudo make altinstall

Be patient as this takes quite some time depending on number of CPU cores in your system. If this was successful, you should get a message like below:

....
running install_scripts
copying build/scripts-3.9/pydoc3.9 -> /usr/local/bin
copying build/scripts-3.9/idle3.9 -> /usr/local/bin
copying build/scripts-3.9/2to3-3.9 -> /usr/local/bin
changing mode of /usr/local/bin/pydoc3.9 to 755
changing mode of /usr/local/bin/idle3.9 to 755
changing mode of /usr/local/bin/2to3-3.9 to 755
rm /usr/local/lib/python3.9/lib-dynload/_sysconfigdata__linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.9/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/python.man \
	/usr/local/share/man/man1/python3.9.1
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--altinstall --upgrade" ;; \
		install|*) ensurepip="--altinstall" ;; \
	esac; \
	 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpxqejw3c3
Processing /tmp/tmpxqejw3c3/setuptools-49.2.1-py3-none-any.whl
Processing /tmp/tmpxqejw3c3/pip-20.2.3-py2.py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The script easy_install-3.9 is installed in '/usr/local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script pip3.9 is installed in '/usr/local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.3 setuptools-49.2.1

Check Python 3.9 installation on CentOS 8 / CentOS 7

Run below command to confirm successful installation of Python 3.9 on CentOS 8 / CentOS 7:

$ python3.9 --version
Python 3.9.1

Pip3.9 must have been installed as well:

$ pip3.9 --version
pip 20.2.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

Here are more guides we have on Python in our website:

Best Books for Learning Python Programming

Install Python 3.8 on CentOS 8 / CentOS 7

Deploy Python 3 Django Application on CentOS 7 with Apache and mod_wsgi

How To Install Python & Django on Debian

Install Python 3 / Python 2.7 on CentOS 8 / RHEL 8

As an appreciation for the content we put out,
we would be thrilled if you support us!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here