Este conteúdo não está disponível no idioma selecionado.
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.
With Red Hat Enterprise Linux, many packages that are installed on the system, such as packages providing system tools, tools for data analysis, or web applications, are written in Python. To use these packages, you must have the python* packages installed.
1.1. Python versions Copiar o linkLink copiado para a área de transferência!
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.
For details about the length of support, see Red Hat Enterprise Linux Life Cycle and Red Hat Enterprise Linux Application Streams Life Cycle.
1.2. Installing Python 3 Copiar o linkLink copiado para a área de transferência!
The default Python implementation is usually installed by default. To install it manually, use the following procedure.
Procedure
To install Python 3.12, enter:
dnf install python3
# dnf install python3Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify the Python version installed on your system:
python3 --version
$ python3 --versionCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.3. Installing additional Python 3 packages Copiar o linkLink copiado para a área de transferência!
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-requests
# dnf install python3-requestsCopy to Clipboard Copied! Toggle word wrap Toggle overflow To install the
pippackage installer from Python 3.12, enter:dnf install python3-pip
# dnf install python3-pipCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4. Installing additional Python 3 tools for developers Copiar o linkLink copiado para a área de transferência!
Additional Python tools for developers are distributed through the CodeReady Linux Builder (CRB) repository.
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-rpms
# subscription-manager repos --enable codeready-builder-for-rhel-10-x86_64-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install, for example, the
python3-cythonpackage:dnf install python3-cython
# dnf install python3-cythonCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.5. Using Python Copiar o linkLink copiado para a área de transferência!
The following procedure contains examples of running 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>
$ python3 $ python3 -m venv --help $ python3 -m pip install <package> $ pip3 install <package>Copy to Clipboard Copied! Toggle word wrap Toggle overflow