Installing Python 3.9 on Rocky / AlmaLinux 8

In today’s tutorial we show you how to install Python 3.9 on a Rocky / AlmaLinux 8 machine. Python is a general-purpose, interpreted, and high-level programming language designed for ease of use, deep integration, and extensibility. By adopting Python, you can do a lot more with powerful libraries and tools like Django, Pygame, Matplotlib, Plotly, and so on.

Highlights of Python 3.9

Below are the key features of the Python 3.9:

  • Annotations for functions and variables that are flexible
  • Python follows a consistent yearly release schedule.
  • Decorators’ Grammar Restrictions Are Being Relaxed.
  • Added os.pidfd open, which provides process management without races or signals.
  • Unicode support updated to version 13.0.0.
  • Python does not leak memory when it is started many times in the same process.
  • C Extension Methods Provide Access to Module State.
  • In the Standard Library, there is support for the IANA Time Zone Database.
  • Prefixes and suffixes are removed using string techniques.

Installation of Python 3.9 on Rocky / AlmaLinux 8 or 9

There are two ways to install Python 3.9;

  1. Install Python 3.9 from official repository.
  2. Download and install Python 3.9 manually.

Method 1: Install Python 3.9 on OS repositories

To install Python 3.9 from it’s official repo on Rocky Linux, perform system updates first:

sudo dnf  -y update

Reboot the system:

sudo reboot

Run the command below to install Python 3.9:

sudo dnf install python39

Press y or Y to accept installation prompt:

Transaction Summary
====================================================================================================================================================================
Install  6 Packages

Total download size: 13 M
Installed size: 45 M
Is this ok [y/N]: y

Run the following command to check Python Version installed:

$ python3.9 --version
Python 3.9.19

Method 2: Download and Install Python 3.9 Manually

We can as well download Python 3.9 archive and install using the steps below.

Step 1: Install Python Dependencies

Install the following software development tools on Rocky Linux 8 in order to build Python 3.9:

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

Now, run the following command to check the availability of gcc.

$ gcc --version
gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10)
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

Using wget command, download Python 3.9 latest release to install:

sudo dnf install wget -y
VERSION=3.9.20
wget https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz

Now, extract the archive file:

tar xvf Python-$VERSION.tar.xz

Change to the directory that was created during the file extraction:

cd Python-$VERSION/
Step 3: Install Python 3.9 on Rocky / AlmaLinux 8

To setup Python installation, use the command below:

./configure --enable-optimizations

Here is the output when successful:

....
checking for build directories... done
checking for -O2... yes
checking for glibc _FORTIFY_SOURCE/memmove bug... no
checking for gcc ipa-pure-const bug... no
checking for stdatomic.h... yes
checking for GCC >= 4.7 __atomic builtins... yes
checking for ensurepip... upgrade
checking if the dirent structure of a d_type field... yes
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 Rocky Linux 8 / AlmaLinux 8:

sudo make altinstall

If the build above is successful, you should get a message like below:

....
/usr/bin/install -c -m 644 ./Misc/python.man \
	/usr/local/share/man/man1/python3.9.19
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--altinstall --upgrade" ;; \
		install|*) ensurepip="--altinstall" ;; \
	esac; \
	 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/include/python3.9/UNKNOWN
sysconfig: /home/rocky/Python-3.9.19/Include/UNKNOWN
WARNING: Additional context:
user = False
home = None
root = '/'
prefix = None
Looking in links: /tmp/tmpfoup6wgl
Processing /tmp/tmpfoup6wgl/setuptools-57.4.0-py3-none-any.whl
Processing /tmp/tmpfoup6wgl/pip-21.2.3-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /usr/local/include/python3.9/setuptools
  sysconfig: /home/rocky/Python-3.9.19/Include/setuptools
  WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /usr/local/include/python3.9/pip
  sysconfig: /home/rocky/Python-3.9.19/Include/pip
  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.
....

Check the installed version as follows:

$ python3.9 --version
Python 3.9.19

# OR
$ /usr/local/bin/python3.9 --version
Python 3.9.20

You can as well use Pip3.9:

 pip3.9 --version

Install Python 3.9 Modules

Use the following command syntax to install Python modules from the modules releases page:

python3.9 -m pip install <module>

Install the following Modules:

python3.9 -m pip install chpl-magic

Run the following command to check the list of installed modules:

python3.9 -m pip list

Conclusion

Our guide on how to install Python 3.9 on Rocky / AlmaLinux 8 is now complete. Python 3.9 is a great way to get started with programming. We hope you found this information useful. If you need any help with the installation, don’t hesitate to contact us and we will be happy to support.

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

The web browser is the key arsenal that we use to browse the internet. If you want to access information […]

In this guide,we will look at how you can install Java 11 on Oracle Linux 8. Java is a widely […]

The adoption of Containers and microservice architectures has been amazing and speedy in the past few years. Docker is widely […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.