Install Python 3.9 on CentOS 8 / CentOS 7

You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose

In today’s guide, you will learn to install Python 3.9 on CentOS 8 / CentOS 7 Linux systems. Python is a general purpose, interpreted and high-level programming language originally created by Guido van Rossum. Python was created for simplicity, deep integration, and excellent scalability.You can use Python to use powerful libraries and tools (including Django, Pygame, Matplotlib, Plotly, etc.) to achieve more goals

In the next part, we will introduce the steps to install Python 3.9 on CentOS 8 / CentOS 7.If you are interested in the complete list of features included with Python 3.9, please check Official release notes.

Install Python 3.9 on CentOS 8 / CentOS 7

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

Step 1: Install Python dependencies

Log in to the CentOS 8 / CentOS 7 system as root or a user with sudo privileges.

$ ssh [email protected]

Then do system update

sudo yum -y update

Install the necessary 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 that 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 the latest Python 3.9 archive

Make sure wget is installed:

sudo yum install wget -y

Use wget to download the latest version Python version 3.9.

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

Use tar to extract the archive file:

tar xvf Python-3.9.1.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 following command to configure the Python installation.

./configure --enable-optimizations

Successful example output:

....
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

Please be patient, as this will take some time, depending on the number of CPU cores in the system. If successful, you will receive the following message:

....
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 the following command to confirm that Python 3.9 is successfully installed on CentOS 8 / CentOS 7:

$ python3.9 --version
Python 3.9.1

Pip3.9 must also be installed:

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

Here are more guides on Python on our website:

The best books to learn Python programming

Install Python 3.8 on CentOS 8 / CentOS 7

Use Apache and mod_wsgi to deploy Python 3 Django applications on CentOS 7

How to install Python and Django on Debian

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

You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose

Sidebar