How to install python3 on RHEL7 and RHEL8 Azure Images.

On the RHEL7 images, Python version 2.7.5 is installed by detault, the python command points to python2 default.

Please note that python3, is only available from RHEL 7.7, you will not be able to install it from the repository if the VM is using a previous release such as RHEL 7.6 or lower, you need to upgrade the VM to RHEL 7.7 to be able to install python3 from the repository.

Once the VM is running RHEL 7.7 or above, python3 can be installed using the following command:

sudo yum install python3 -q -y

Result:

$ python --version
Python 2.7.5
$ python2 --version
Python 2.7.5
$ python3 --version
Python 3.6.8

On RHEL8, Python version 3.6.8 is installed by default, the python command is not set, you need to use the python3 command, to make python points to python3 use the following command:

sudo alternatives --set python /usr/bin/python3

Result:

$ python --version
Python 3.6.8

End