Python 3 is available on RHEL 8 through the AppStream module system, which lets you install and switch between multiple Python versions without compiling from source. Unlike older RHEL releases, RHEL 8 ships with Python 3.6, 3.8, 3.9, and (via later AppStream streams) 3.11 all coexisting on the same system. This tutorial shows you how to install your preferred Python 3 version, install and upgrade pip, manage packages, and understand important RHEL-specific conventions like always using python3 instead of python.
Prerequisites
- RHEL 8 system with an active subscription or CentOS Stream 8
- Root or
sudoaccess - Internet access or a local package mirror
- EPEL 8 enabled if you need additional Python packages not in AppStream
Step 1 — Check Available Python Streams
RHEL 8 AppStream delivers Python via modules. List the available streams before installing anything so you know which versions are on offer.
dnf module list python3
dnf module list python39
dnf module list python311
The d flag in the output marks the default stream and [e] marks an enabled one. The base system ships with Python 3.6 at /usr/libexec/platform-python, which is reserved for system tools and should not be used for application development.
Step 2 — Install Python 3.9 or 3.11
Enable the desired module stream and install Python along with pip and the development headers. Python 3.9 is the most widely used AppStream version on RHEL 8; Python 3.11 became available in later AppStream updates.
dnf module install -y python39
# or for Python 3.11:
# dnf module install -y python3.11
python3.9 --version
which python3.9
The executable lands at /usr/bin/python3.9. A python3 symlink points to whichever version was most recently made the system default via the alternatives system.
Step 3 — Install and Upgrade pip
Install pip via dnf to get the system-managed package, then upgrade it to the latest version with pip itself so you have access to the newest resolver and wheel support.
dnf install -y python3-pip
pip3 install --upgrade pip
pip3 --version
python3 -m pip --version
On RHEL 8 you may see a warning about running pip as root modifying system packages. Use virtual environments (covered in the next tutorial) for all application-level package installations to avoid polluting the system Python.
Step 4 — Install Python Packages
With pip available, install commonly needed packages. Always use pip3 or python3 -m pip — never the bare pip command, which may point to a Python 2 installation on some systems.
pip3 install requests flask
pip3 install --upgrade requests
pip3 list
pip3 show requests
Step 5 — Configure the Alternatives System
If you need python3 to resolve to a specific version, use the alternatives system. This is the RHEL-recommended way to manage the default Python 3 interpreter without overwriting symlinks manually.
alternatives --set python3 /usr/bin/python3.9
python3 --version
# To list all registered alternatives:
alternatives --list | grep python
Never create a /usr/bin/python symlink pointing to Python 3 without understanding which system scripts depend on Python 2. RHEL 8 deliberately ships without a bare python command to avoid ambiguity.
Step 6 — Verify the Installation
Run a quick end-to-end check to confirm Python, pip, and the installed packages are all working correctly.
python3 --version
python3 -c "import sys; print(sys.executable)"
python3 -c "import requests; print(requests.__version__)"
python3 -m flask --version
pip3 list | head -20
Conclusion
You have installed Python 3.9 (or 3.11) on RHEL 8 using AppStream modules, upgraded pip to the latest version, installed packages with pip3, configured the alternatives system to set the default interpreter, and verified the installation end-to-end. The key RHEL 8 conventions to remember are always using python3 explicitly, installing packages into virtual environments rather than system-wide, and never touching the platform Python at /usr/libexec/platform-python.
Next steps: How to Use Python Virtual Environments on RHEL 8, How to Deploy a Django Application with Gunicorn and Nginx on RHEL 8, and How to Install and Use Ansible on RHEL 8.