Red Hat Enterprise Linux (RHEL) 8 comes with Python 3.6 pre-installed. However, if you need to install a different version of Python, you can use the dnf
package manager to install Python from the default package repository.
To install Python 3, use the following command:
sudo dnf install python3
This will install the latest version of Python 3 that is available in the default package repository.
To install a specific version of Python 3, you can use the dnf
command with the --releasever
option and specify the version number. For example, to install Python 3.8, you can use the following command:
sudo dnf install python38 --releasever=8
Note that you may need to enable the optional package repository in order to install a version of Python that is not available in the default repository. You can do this by running the following command:
sudo dnf config-manager --set-enabled PowerTools
To install Python 2 on RHEL 8, you will need to enable the EPEL repository and install the python2
package. You can do this by running the following commands:
sudo dnf install epel-release sudo dnf install python2
Keep in mind that Python 2 is no longer actively maintained and it is recommended to use Python 3 instead.