Python 2.7 is available in the RHEL 8 AppStream repository (package python2). Please do not combine repositories for different major versions of RHEL/CentOS, this is not supported and as you can see not possible.

# dnf info python2
Available Packages
Name         : python2
Version      : 2.7.18
Release      : 6.module_el8.5.0+772+8dae0bfd
Architecture : x86_64
Size         : 109 k
Source       : python2-2.7.18-6.module_el8.5.0+772+8dae0bfd.src.rpm
Repository   : appstream
Summary      : An interpreted, interactive, object-oriented programming language
...

Note that official support for Python 2 ended in 2020 and Red Hat will provide security updates only until 2024.

Answer from Vojtech Trefny on Stack Exchange
๐ŸŒ
TecAdmin
tecadmin.net โ€บ install-python-2-7-on-centos-rhel
How to Install Python 2.7 on CentOS/RHEL 9/8 and Fedora
April 26, 2025 - Learn to install Python 2.7 on CentOS, RHEL & Fedora. Our guide covers the full process, ensuring a secure setup for legacy applications.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 78371241 โ€บ install-python2-7-on-rehl-9-for-legacy-application
python 2.7 - install python2.7 on rehl 9 for legacy application - Stack Overflow
Just download the file, make it executable, rename it "python2" or create a symlink of that name pointing to the AppImage file, and put it in /usr/local/bin/, and getmail will happily run with it.
Discussions

Python2 support
Python 2 has been deprecated and received no updates in 2 years. It is well and truly dead. More on reddit.com
๐ŸŒ r/redhat
11
7
March 31, 2022
Unable to install python 2.7 on RHEL - Unix & Linux Stack Exchange
I am unable to install python 2.7 in my RHEL8. It already bothers me that I cannot find the python package outside of the Centos7 repository, but when I try to install there is a ton of broken More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
August 6, 2021
python - Install alternate version of python2.7.9 on rhel7.2 - Stack Overflow
RHEL7.2 comes with python2.7.5 I want to install an alternate version of 2.7 (2.7.9) but it keeps messing with my preinstalled version (since both are python2.7). I run: ./configure --enable-sha... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Install Python 2.7.5 on Redhat 8 - Stack Overflow
I am trying to install python 2.7.5 on a Red hat 8.5 machine. Right now there is no python installed on this box so its going to be a fresh install. However, I am getting into a lot of dependency i... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Red Hat
access.redhat.com โ€บ solutions โ€บ 4455511
How is Python 2 supported in RHEL after 2020? - Red Hat Customer Portal
August 9, 2024 - RHEL 8.0 Release Notes - 5.1.7. ... at: RHEL 8 - Installing, managing, and removing user space components ยท Python 2 is not distributed with RHEL 9 and not planned for any future RHEL releases....
๐ŸŒ
Red Hat
developers.redhat.com โ€บ blog โ€บ install-python3-rhel
How to install multiple versions of Python on Red Hat Enterprise Linux | Red Hat Developer
February 27, 2024 - This article shows how to install Python on Red Hat Enterprise Linux (RHEL), including both versions 3 and 2 of Python along with the pip, vent, virtualenv, and pipenv utilities. The article starts with RHEL 9 and continues with RHEL 8 and RHEL 7, including plenty of tips useful in all versions.
๐ŸŒ
DataStax
docs.datastax.com โ€บ en โ€บ jdk-install โ€บ doc โ€บ jdk-install โ€บ installPython27RHEL.html
Install DataStax Enterprise 6.8 on Debian-based systems using APT | DataStax Docs
Python 3.8 through 3.11, or Python 2.7.x. Each listed version provides support for cqlsh, but DataStax recommends using Python 3.11. If you have an older RHEL distribution, such as CentOS 6.5, you must install Python 2.7:
๐ŸŒ
IBM
ibm.com โ€บ docs โ€บ en โ€บ oala โ€บ 1.3.8
Installing Python 2.7.18
July 2, 2018 - Install Python 2.7.18 if you use IBM Operations Analytics Log Analysis on Red Hat Enterprise (RHEL) Linux 9 or SUSE Linux Enterprise Server (SLES) 15.
Find elsewhere
๐ŸŒ
IBM
ibm.com โ€บ support โ€บ pages โ€บ how-install-python-27x-your-own-rhel-build-integration-server
How to install Python 2.7.x on your own RHEL to build an integration server
March 24, 2020 - The Python version is lower than Resilient integation prerequisite, which requires Python 2.7.9 or a higher version. You can install the (current) latest Python 2.7.16 or any version higher than Python 2.7.9 follow the procedure below. ... To install the package via yum, your RHEL must be an ...
๐ŸŒ
ComputingForGeeks
computingforgeeks.com โ€บ home โ€บ install python 3 / python 2.7 on centos 8|rhel 8
Install Python 3 / Python 2.7 on CentOS 8|RHEL 8 [Guide]
August 21, 2023 - python3.9 Python 3.9.16 (main, Jul 3 2023, 20:07:32) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> ... For some guys with existing software not ready to run on Python 3, RHEL/CentOS 8 got you covered. It contains the Python 2 stack. Install Python 2.7 on CentOS 8 / RHEL 8 in parallel with Python 3 using the command:
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 39385617 โ€บ install-alternate-version-of-python2-7-9-on-rhel7-2
python - Install alternate version of python2.7.9 on rhel7.2 - Stack Overflow
That wasn't good as it always linked the python to the newly installed one. Changing the line to the following fixed the problem: Copygrep "/usr/local/lib/" /etc/ld.so.conf || (echo "/usr/lib\n/usr/local/lib/" >> /etc/ld.so.conf && /sbin/ldconfig) ... Regarding the flags on make, I still don't know what they do... ... Thanks @garg10may. I found the problem and edited my question accordingly ... Two versions of python on linux. how to make 2.7 the default
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 70727349 โ€บ install-python-2-7-5-on-redhat-8
Install Python 2.7.5 on Redhat 8 - Stack Overflow
The source for 2.7.5 is here. It's possible you could collect all the .el7 RPMs and force them to install in RHEL 8, but then you're going to be dealing with dependency chains going right back to libc and other base libs, and that would probably turn out to be a bigger pain than installing everything from source. Python doesn't have that many dependencies, and especially if you know which modules you need and which ones you don't for your application, you can skip installing some of them.
๐ŸŒ
Red Hat
access.redhat.com โ€บ solutions โ€บ 92933
Adding Python 2.7 to RHEL6 - Red Hat Customer Portal
We would like to have Python version 2.7 installed and supported by Red Hat in Red Hat Enterprise Linux 6 (RHEL6).
๐ŸŒ
nixCraft
cyberciti.biz โ€บ nixcraft โ€บ howto โ€บ package management โ€บ rhel 8 install python 3 or python 2 using yum
RHEL 8 install Python 3 or Python 2 using yum - nixCraft
May 23, 2024 - By default, no version of Python installed on RHEL 8. We will show you how to install either Python 2.7/3.8 on RHEL 8 using the DNF/YUM CLI.
Top answer
1 of 11
128

Instructions to download source and install:

https://www.python.org/download/

NOTE: You should check for the latest version of python 2.7.x, as it gets updated frequently. Currently (Oct 2017), the latest version is 2.7.14 though this comment will get old and new versions likely will be released every 6 months or so.

wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz # Download
tar xvfz Python-2.7.14.tgz # unzip
cd Python-2.7.14 # go into directory
./configure
make # build
su # or 'sudo su' if there is no root user
make altinstall

(EDIT: make install -> make altinstall per Ignacio's comment).

2 of 11
13

RHEL 6.2 using (had Python 2.6, i need Python 2.7.3) So:

$ sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python27.repo >> /etc/yum.repos.d/scl.repo'

$ yum search python27
Loaded plugins: amazon-id, rhui-lb, security
scl_python27                                                                                                                                      | 2.9 kB     00:00     
scl_python27/primary_db                                                                                                                           |  38 kB     00:00     
========================================================================= N/S Matched: python27 =========================================================================
python27.i686 : Package that installs python27
python27.x86_64 : Package that installs python27
python27-expat-debuginfo.i686 : Debug information for package python27-expat
python27-expat-debuginfo.x86_64 : Debug information for package python27-expat
python27-python-coverage-debuginfo.i686 : Debug information for package python27-python-coverage
python27-python-coverage-debuginfo.x86_64 : Debug information for package python27-python-coverage
python27-python-debuginfo.i686 : Debug information for package python27-python
python27-python-debuginfo.x86_64 : Debug information for package python27-python
python27-python-markupsafe-debuginfo.i686 : Debug information for package python27-python-markupsafe
python27-python-markupsafe-debuginfo.x86_64 : Debug information for package python27-python-markupsafe
python27-python-simplejson-debuginfo.i686 : Debug information for package python27-python-simplejson
python27-python-simplejson-debuginfo.x86_64 : Debug information for package python27-python-simplejson
python27-python-sqlalchemy-debuginfo.i686 : Debug information for package python27-python-sqlalchemy
python27-python-sqlalchemy-debuginfo.x86_64 : Debug information for package python27-python-sqlalchemy
python27-runtime.i686 : Package that handles python27 Software Collection.
python27-runtime.x86_64 : Package that handles python27 Software Collection.
python27-babel.noarch : Tools for internationalizing Python applications
python27-build.i686 : Package shipping basic build configuration
python27-build.x86_64 : Package shipping basic build configuration
python27-expat.i686 : An XML parser library
python27-expat.x86_64 : An XML parser library
python27-expat-devel.i686 : Libraries and header files to develop applications using expat
python27-expat-devel.x86_64 : Libraries and header files to develop applications using expat
python27-expat-static.i686 : expat XML parser static library
python27-expat-static.x86_64 : expat XML parser static library
python27-python.i686 : An interpreted, interactive, object-oriented programming language
python27-python.x86_64 : An interpreted, interactive, object-oriented programming language
python27-python-babel.noarch : Library for internationalizing Python applications
python27-python-coverage.i686 : Code coverage testing module for Python
python27-python-coverage.x86_64 : Code coverage testing module for Python
python27-python-debug.i686 : Debug version of the Python runtime
python27-python-debug.x86_64 : Debug version of the Python runtime
python27-python-devel.i686 : The libraries and header files needed for Python development
python27-python-devel.x86_64 : The libraries and header files needed for Python development
python27-python-docutils.noarch : System for processing plaintext documentation
python27-python-jinja2.noarch : General purpose template engine
python27-python-libs.i686 : Runtime libraries for Python
python27-python-libs.x86_64 : Runtime libraries for Python
python27-python-markupsafe.i686 : Implements a XML/HTML/XHTML Markup safe string for Python
python27-python-markupsafe.x86_64 : Implements a XML/HTML/XHTML Markup safe string for Python
python27-python-nose.noarch : Discovery-based unittest extension for Python
python27-python-nose-docs.noarch : Nose Documentation
python27-python-pygments.noarch : Syntax highlighting engine written in Python
python27-python-setuptools.noarch : Easily build and distribute Python packages
python27-python-simplejson.i686 : Simple, fast, extensible JSON encoder/decoder for Python
python27-python-simplejson.x86_64 : Simple, fast, extensible JSON encoder/decoder for Python
python27-python-sphinx.noarch : Python documentation generator
python27-python-sphinx-doc.noarch : Documentation for python-sphinx
python27-python-sqlalchemy.i686 : Modular and flexible ORM library for python
python27-python-sqlalchemy.x86_64 : Modular and flexible ORM library for python
python27-python-test.i686 : The test modules from the main python package
python27-python-test.x86_64 : The test modules from the main python package
python27-python-tools.i686 : A collection of development tools included with Python
python27-python-tools.x86_64 : A collection of development tools included with Python
python27-python-virtualenv.noarch : Tool to create isolated Python environments
python27-python-werkzeug.noarch : The Swiss Army knife of Python web development
python27-python-werkzeug-doc.noarch : Documentation for python-werkzeug
python27-tkinter.i686 : A graphical user interface for the Python scripting language
python27-tkinter.x86_64 : A graphical user interface for the Python scripting language

  Name and summary matches only, use "search all" for everything.

EDIT:

CentOS 6.x: http://dev.centos.org/centos/6/SCL/x86_64/python27/

$ sudo sh -c 'wget -qO- http://dev.centos.org/centos/6/SCL/scl.repo >> /etc/yum.repos.d/scl.repo'
$ scl enable python27 'python --version'
python 2.7.5
$ scl enable python27 bash
$ python --version
Python 2.7.5
๐ŸŒ
Greenwebpage
greenwebpage.com โ€บ home โ€บ blog โ€บ how to install python on red hat enterprise linux 9
How to Install Python on Red Hat Enterprise Linux 9 - Greenwebpage Community
March 30, 2024 - After running the update command, execute โ€œsudo dnf install python3.11โ€ to set up the Python files on your system. You can also install additional packages associated with Python 3.11 via โ€œsudo dnf install python3.11-pipโ€.
๐ŸŒ
Red Hat
access.redhat.com โ€บ discussions โ€บ 4819071
Red Hat Customer Portal - Access to 24x7 support and knowledge
February 11, 2020 - With RHEL 7 , we have Python 2.7 by default but now with Python 2 project gone obsolete , we have to move the setups one by one to Python 3. Now for such transition , we as of now need to have both the environment go hand-in-hand on server Python 2 as well as Python 3 . Can someone please provide me with best practices to go about it . Also, industry-wide best practices on how to install pip, how use it (sudo/root/user?) to install other python packages and how to differentiate from python3 and pip3 packages?
๐ŸŒ
LinuxConfig
linuxconfig.org โ€บ home โ€บ install python 2 on rhel 8 / centos 8
Install Python 2 on RHEL/CentOS 8 - Easy Steps
September 24, 2019 - Learn how to install Python 2 on RHEL 8/CentOS 8 with a simple dnf command. Verify installation and understand software requirements easily.