After completing this section, students should be able to identify, install, and control the specific versions of Python available to a server.
The RHEL 8 default minimum installation does not install the user-level Python binaries, only the version for operating system tooling. The Python 2.7 and Python 3.6 application binaries are available from the Application Stream (AppStream) repository for Red Hat Enterprise Linux 8.
Installing Python on RHEL 8
RHEL 8 includes Yum modules for both Python 2.7 and Python 3.6.
Python 3.6 is the default. Python 2.7 is a short life release to assist users to migrate to RHEL 8 while their applications are being ported to python3.
Future releases of Python 3.x will be available from the AppStream repository as Yum modules named python3.
x
Working with Python in Red Hat Enterprise Linux 8
By default, Red Hat Enterprise Linux 8 does not provide a /usr/bin/python command. Use the alternatives command to link to the desired release for command line simplicity.
Do not use /usr/bin/python in scripts. Always write scripts using /usr/bin/python3 or /usr/bin/python2, because their behavior will always be version dependent.
System tools written in Python use separate python3 installation called /usr/libexec/platform-python. Do not use this version in your scripts as it only includes python modules required for operating system tooling.
Setting up Alternative Python Versions
The Python 2.7 module installs the /usr/bin/python2 binary. Python 3.6 installs the /usr/bin/python3 binary. Use the alternatives command to link /usr/bin/python to either /usr/bin/python2, or /usr/bin/python3, recommended only for interactive use.
For more information, refer to the Using Python in Red Hat Enterprise Linux 8 chapter in the Red Hat Enterprise Linux 8 Configuring Basic System Settings Guide at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_basic_system_settings/index#using-python3_configuring-basic-system-settings