How to Install Python 3.9 on Rocky Linux 8

Python is a programming language that can be used to create just about anything. From full-scale games to web applications, and even simple scripts for your PC or Mac. Python has been around since the late 1980s and continues to be one of the most popular languages in use today.

Today’s tutorial will show you how to install Python 3.9 programming language on a Rocky Linux 8 system.


  • A Rocky Linux 8 system. Any relatively recent version of Rocky Linux should work fine with this instructions. 
  • A non-root user with sudo privilege set up on your Rocky system.

Updating the System

The first thing we need to do is update the system software packages. This ensures that our entire system has been updated, and updated to the latest stable versions, before we start installing Python.

sudo dnf -y update

Install Python 3.9 Using the Official Repository

As of this writing, the default Rocky Linux 8 AppStream repository has Python v3.7, v3.8, and v3.9.

Run the following command to install the latest Python version.

sudo dnf install python39

Click Y and hit Enter when prompted. The installation process will begin.

install python39

Once the installation is complete, run the following command to verify that your Python version.

python3.9 --version

python3.9 --version

Python 3.9 should now be installed on your Rocky system and ready for use.

Installing Python 3.9 Manually

If you do not have access to the AppStream repository or prefer installing from a different source, you can install Python 3.9 manually using the Python 3.9 archive. To begin the installation process, open up your terminal and run the following command to install the necessary packages to compile Python packages on Rocky Linux 8.

sudo dnf groupinstall "Development Tools" -y

Next, run the following command to install the necessary dependencies. Such as openssl-devel, libffi-devel.

sudo dnf install openssl-devel libffi-devel bzip2-devel -y

Now, dowload the latest version of Python using the wget command. Extract the zip file, and move into the extracted directory.

sudo dnf install wget -y
tar xvf Python-3.9.7.tar.xz
cd Python-3.9.7/

Once you in the /Python-3.9.7/ directory. Run the following command to configure the source code and install the Python packages.

./configure --enable-optimizations
sudo make altinstall

We use altinstall instead to make install because the latter will overwrite any existing Python binary. We need Python 3.9 to coexist on the same system with 3.7 or any other version of Python installed. Otherwise, you will not be able to use multiple versions at once.

This command takes quite some time to complete because this command compiles a large number of packages used by Python. Please be patient and wait for the installation to complete.

If the Python installation was successful, you should get a message like below.

altinstall python

Run the following command to verify your Python version.

python3.9 --version

 You should get an output like the one below.

python3.9 --version

Installing Python 3.9 Modules

Now that we have Python and all of its dependencies installed, we can install our desired modules.

Run the following command to download and install the requests module for Python 3.9.

python3.9 -m pip install <module>

Where: <module> is the name of the module that you want to install. You can get a comprehensive list of available modules on the official page

For example, we will install the requests module.

python3.9 -m pip install requests

If no errors are encountered during the installation process, then your desired Python modules should be ready for use on your system.

python3.9 install requests

To see which modules are installed on the server, type this command.

python3.9 -m pip list

You should get an output like the one below.

python3.9  list modules

Testing the Python Installation

Now that you have Python 3.9 installed, let's test it. Run the following command to create create a test file with your favorite text editor, such as vi or nano. The name of this file is how you will run the Python program from now on without specifying the full path to the file.

cd Python-3.9.7
sudo nano

Copy and paste the following code into your file, save your changes to the file, and exit your editor.

print("Howtoforge, HelloWorld!")

Now we can run this program by typing:


If all is working correctly you should get a Hello World message.

testing python 3.9


In this guide, we have learned how to install Python 3.9 script language on Rocky Linux 8. We can now use Python for programming and writing scripts.

If you have any questions or concerns, please leave a comment below.

Share this page:

0 Comment(s)