Menu Close

Chapter 2. Installing and using Python

In RHEL 9, Python 3.9 is the default Python implementation. The unversioned python command points to the default Python 3.9 version.

2.1. Installing Python 3

The default Python implementation is usually installed by default. To install it manually, use the following procedure.


  • To install Python, use:

    # dnf install python3

Verification steps

  • To verify the Python version installed on your system, use the following command:

    $ python3 --version

2.2. Installing additional Python 3 packages

Packages prefixed with python3 contain modules for the default Python 3.9 version.


  • To install the Requests module for Python, use:

    # dnf install python3-requests
  • To install the pip package installer from Python, use:

    # dnf install python3-pip

2.3. Installing additional Python 3 tools for developers

Additional Python tools for developers are distributed through the CodeReady Linux Builder repository.

This repository contains, for example, the python3-pytest, python3-Cython packages and many others.


The CodeReady Linux Builder repository and its content is unsupported by Red Hat.

To install packages from the repository, use the following the procedure.


  1. Enable the CodeReady Linux Builder repository:

    # subscription-manager repos --enable codeready-builder-for-rhel-9-x86_64-rpms
  2. Install the python3-pytest package:

    # dnf install python3-pytest

2.4. Using Python

The following procedure contains examples of running the Python interpreter or Python-related commands.


  • Ensure that Python is installed.


  • To run the Python interpreter or related commands, use, for example:

    $ python3
    $ python3 -m pip --help
    $ python3 -m pip install package