A Complete Guide on How to Install Python 3.12 on RHEL 10
Python is a high-level coding language that supports multiple programming paradigms, and 3.12.0 is the newest major release of the Python programming language. The version contains many new features and optimizations, such as more flexible f-string parsing, support for the buffer protocol in Python code (PEP 688), isolated sub-interpreters with separate Global Interpreter Locks (PEP 684), Linux perf profiler to report Python function names in traces, and more. With many large and small performance improvements like PEP 709 and support for the BOLT binary optimizer, it delivers an estimated 5% overall performance improvement.
In this tutorial 24*7 guide, we will discuss the installation of Python 3.12 on RHEL (Red Hat Enterprise Linux) 10. With RHEL, many packages are installed on the system. For example, you may leverage packages that provide system tools, data analytic tools, or web applications written in Python. All you need to use these packages is to have Python 3.12 installed.
Continue reading!
Python versions and RHEL 10
Python 3.12 is the default Python implementation in RHEL 10 and is distributed in a non-modular python3 RPM package in the BaseOS repository. It is usually installed by default and will be supported for the whole RHEL 10 life cycle.
Note:
- 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, and you can install these in parallel with Python 3.12.
- The unversioned Python command points to the default Python 3.12 version.
How to install Python 3.12 on RHEL 10?
The default Python implementation is usually installed by default on RHEL 10. To install it manually, use the following command in CMD:# dnf install python3
Next, verify the installation of Python 3.12 on RHEL 10 with the command:
$ python3 --version
For additional Python 3.12 packages, use the following command:
# dnf install python3-request
It installs the Requests module for Python 3.12.
# dnf install python3-pip
It installs the pip package installer from Python 3.12.
Note: Packages prefixed with python3- contain add-on modules for the default Python 3.12 version.
Installing Additional Python 3 Tools for Developers
Additional Python tools for developers are distributed through the CodeReady Linux Builder (CRB) repository. Some CRB repository packages are:
- python3-pytest
- python3-idle
- python3-debug
- python3-cython
Note: Not all upstream Python-related packages are available in RHEL.
Install additional Python 3 tools:
# subscription-manager repos --enable codeready-builder-for-rhel-10-x86_64-rpms
The command enables the CodeReady Linux Builder repository.
# dnf install python3-cython
The command installs the python3-cython package.
Note: You can further check how to enable and use content within CodeReady Linux Builder by clicking here.
Using Python
In this section, we will discuss the procedure containing examples of running the Python interpreter or Python-related commands. All you need is to have Python installed.
Note:
- For developers who want to download and install third-party applications, you should install the python3-pip package.
To run the Python 3.12 interpreter or related commands, use the following commands:
$ python3
$ python3 -m venv --help
$ python3 -m pip install <package>
$ pip3 install <package>
Python 3.12 will be supported throughout the entire lifecycle of RHEL 10.
Conclusion
Python 3.12, the standard Python interpreter in RHEL 10, comes as a Python3 RPM package. Hence, it's part of the core system, not a modular package. It is typically installed by default, so you won't need to install it manually. Packages prefixed with python3- contain add-on modules for the default Python 3.12 version. For a smoother transition from previous RHEL versions, Python 3.12 is also provided for RHEL 8 and RHEL 9 as the latest alternative Python stack.