Files
gitea-pages/admin-guide/configuration/python.md

1.7 KiB

Python

There are several versions of Python available from RedHat. This guide shows how you can select a specific version to be selected and used on your system.

The use of environment like venv or Conda is recommended if a single user needs one or multiple specific Python environments. But this is not part of this guide.

This guide is only for RHEL8 and newer.

Python 3

In Hiera you can select the wished version of Python

base::python::version: '3.11'

The python as well as the python3 command will then link to the interpreter of given version. The same is for pip and pip3.

RHEL8

On RHEL8 the default Python version is 3.6. Available are also

  • 3.8
  • 3.9
  • 3.11

RHEL9

On RHEL9 the default Python version is 3.9. Available are also

  • 3.11
  • 3.12

Libraries

The packages prefixed with python3- are for the default Python version. For newer versions they have a versioned prefix like python38- or python3.11-. There might not be for all libraries packages for all availabe Python versions. Then you might need to install your library with pip.

For package installation (including with pip) with Hiera please check out this guide.

Note that packages installed with pip are not updated automatically.

Python 2

Don't use.

Platform Python

For system tools, which are shared over many systems where maybe different Python versions are used by default, you may select to use "Platform Python" instead, which is always the default Python version, independed of what has been selected as default Python.

For this you need to set the shebang of your script to

#!/usr/libexec/platform-python