How to Install Python 3 or Python 2 in RHEL 8

In RedHat Enterprise Linux 8, Python doesn’t come preinstalled. The main reason for this is that the RHEL 8 developers didn’t want to set a default Python version for users. Therefore as a RHEL user, you need to specify whether you want Python 3 or 2 by installing it. In addition, in RHEL, Python 3.6 is the default and fully supported version of Python. However, Python 2 remains available and you can install it.

In this short article, we will show how to install Python 3 and Python 2, and run them in parallel in RHEL 8 Linux distribution.


  1. RHEL 8 with Minimal Installation
  2. RHEL 8 with RedHat Subscription Enabled
  3. RHEL 8 with Static IP Address

Important: Most Linux distributions use Python for a number of libraries and tools as YUM package manager. Although Python is not installed in RHEL 8 by default, but yum still works even if you don’t install Python. This is because there is an internal Python interpreter called “Platform-Python” which is used by system tools. Platform-python can’t be used by applications but you can only employ it for writing system/administrative code.

How to Install Python 3 in RHEL 8

To install Python 3 on your system, use the DNF package manager as shown.

# dnf install python3
Install Python 3 in RHEL 8
Install Python 3 in RHEL 8

From the output of the command, Python3.6 is the default version which comes with PIP and Setuptools as dependencies.

How to Install Python 2 in RHEL 8

If you want to install Python 2 in parallel with Python 3, run the following command which will install Python 2.7 on your system.

# dnf install python2
Install Python 2.7 in RHEL 8
Install Python 2.7 in RHEL 8

How to Run Python in RHEL 8

After installing Python, you would expect that /usr/bin/python will run a certain version of Python. To dissociate itself from “Python2 or Python3: which version should be set as the default on Linux” debates, RedHat has not included a python command by default – what is referred to as the “unversioned command“.

To run Python 3, type:

# python3

And to run Python 2, type:

# python2

What if there are applications/programs on your system that expect a python command to exist, what do you need to do? It is simple, you use alternatives --config python command to easily make /usr/bin/python point to the correct location of the Python version you want to be set as the default version.

For example:

# alternatives --set python /usr/bin/python3
# alternatives --set python /usr/bin/python2

That’s All! In this short article, we have shown how to install Python 3 and Python 2 on RHEL 8. You can ask questions or share your thoughts with us via the feedback form below.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.