Chapter 1. Installing and using Python
Python is a high-level programming language that supports multiple programming paradigms, such as object-oriented, imperative, functional, and procedural paradigms. Python has dynamic semantics and can be used for general-purpose programming.
Many installed packages on Red Hat Enterprise Linux are written in Python. Examples include packages for system tools, data analysis, and web applications. To use these packages, you must have the python* packages installed.
1.1. Python versions Copy linkLink copied to clipboard!
To select the appropriate environment for developing and running your applications, review Python versions available in Red Hat Enterprise Linux (RHEL) 10.
Python 3.12 is the default Python implementation in RHEL 10. Python 3.12 is distributed in a non-modular python3 RPM package in the BaseOS repository and is usually installed by default. Python 3.12 will be supported for the whole life cycle of RHEL 10.
Additional versions of Python 3 will be distributed as non-modular RPM packages with a shorter life cycle through the AppStream repository in minor RHEL 10 releases. You will be able to install these additional Python 3 versions in parallel with Python 3.12.
The unversioned python command points to the default Python 3.12 version.
1.2. Installing Python 3 Copy linkLink copied to clipboard!
To develop and run Python applications, install Python 3 on your RHEL 10 system.
The default Python implementation is usually installed by default. However, you can also install it manually.
Procedure
To install Python 3.12, enter:
# dnf install python3
Verification
Verify the Python version installed on your system:
$ python3 --version
1.3. Installing additional Python 3 packages Copy linkLink copied to clipboard!
To extend the capabilities of your applications and scripts, install additional Python 3 packages on your RHEL 10 system.
Packages prefixed with python3- contain add-on modules for the default Python 3.12 version.
Procedure
To install, for example, the
Requestsmodule for Python 3.12, enter:# dnf install python3-requestsTo install the
pippackage installer from Python 3.12, enter:# dnf install python3-pip
1.4. Installing additional Python 3 tools for developers Copy linkLink copied to clipboard!
To get additional Python tools for developers, use the CodeReady Linux Builder (CRB) repository. Install the python3 packages that provide the tools you need.
The content in the CodeReady Linux Builder repository is unsupported by Red Hat.
The CRB repository contains, for example, the following packages:
-
python3-pytest -
python3-idle -
python3-debug -
python3-cython
Not all upstream Python-related packages are available in RHEL.
Procedure
Enable the CodeReady Linux Builder repository:
# subscription-manager repos --enable codeready-builder-for-rhel-10-x86_64-rpmsInstall, for example, the
python3-cythonpackage:# dnf install python3-cython
1.5. Using Python Copy linkLink copied to clipboard!
To install or interact with packages providing system tools, tools for data analysis, or web applications written in Python, run the Python interpreter or Python-related commands.
Prerequisites
- Python is installed.
If you want to download and install third-party applications, install the
python3-pippackage.WarningInstalling Python packages with
pipas the root user places files in system locations. This can override RHEL libraries and might cause system instability or conflicts with supported packages. Red Hat does not support software installed by usingpipat the system level. To avoid these issues, usepipwithin a virtual environment or install packages as a non-root user with the--useroption.
Procedure
To run the Python 3.12 interpreter or related commands, use, for example, the following commands:
$ python3 $ python3 -m venv --help $ python3 -m pip install <package> $ pip3 install <package>