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.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

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

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.