How to Install Python3 RHEL6
Note: This also works on CentOS Version 6. The procedure was fully tested as working on Python3 RHEL6 and CentOS6 (March 2023)
A large number of operating system applications require Python. Out of the box, Red Hat 6 versions only support Python2.6, and Red Hat 7 versions only support Python2.7. Both of these versions are deprecated as of January 2021 despite RHEL6 being in an extended life phase. Python will still work, but Red Hat will provide no further support or security updates.
In RHEL6, if you type yum install python3, you will get an error that the file does not exist.
The problem is that the default yum repositories for Red Hat 6 are not being updated with the latest versions of Python, but the new versions are available in the Red Hat Software Collections repo, however, this repo is not enabled by default.
If you were to try a yum install python 3, python 3.8, a major release, or the latest release, the job would fail with this error message.
Therefore, you have 2 options.
- Install Python from the source code.
- Install Python from Red Hat Software Collections.
How to install Python 3.9 from the source code
The cleanest way to install Python 3.9 is to install it from the source code.
This is how you do it:
Step 1 – Yum Update and Install Pre-Reqs
If you have any issues updating yum due to CentOS/RHEL6 going to end of life, follow this procedure to fix the problem.
Check the Python Website for the latest version for your operating system. Python is updated regularly, so it’s more than likely that there is a newer edition already.
Step 3 – Extract the Python download.
Step 4 – Navigate to the new folder
Step 5 – Prepare the source code for the build; this will be a local install with PIP baked in
Step 6 – Install Python
Please note that we will use ALT INSTALL and RHEL6 uses Python2 for system applications such as yum
You can use the latest version of python by prefixing the commands with python3.9
Or you can add create an alias for Python3.9 and Pip.39
You will see out like this:
You must exit the shell and log back in to make the change.
Install Python36 from the Red Hat Software Collection Repo
To install Python from Red Hat Software Collections on a Red Hat Enterprise Linux (RHEL) system, follow these steps:
Step1 – Enable RHEL Software Repo
Enable the Red Hat Software Collections repository by running the following command:bash
Note that the repository name may differ depending on the version of RHEL you are using.
Step 2 – Instal RHEL Software Utility
Install the Software Collections Utility package by running the following command:
Step 3 – Install Python 36
Install Python 3 by running the following command:
This command will install Python 3.6 from the Red Hat Software Collections repository.
Step 4 – Enable Python36 on the shell
To use Python 3.6, you will need to enable the Software Collection by running the following command:
This command will start a new Bash shell with the Software Collection enabled.
Alternatively, you can also use the following command to run Python 3.6 directly:
This will launch the Python 3.6 interpreter.
That’s it! You should now have Python 3.6 installed from the Red Hat Software Collections repository on your RHEL system.
Thanks for taking the time to read this article. if you have any questions or feedback, please write in the comment section below.