diff --git a/_toc.yml b/_toc.yml index 05ef5e39..bb7f17c8 100644 --- a/_toc.yml +++ b/_toc.yml @@ -39,6 +39,7 @@ chapters: sections: - file: admin-guide/configuration/icinga2 - file: admin-guide/configuration/packages + - file: admon-guide/configuration/python - file: admin-guide/configuration/package_updates - file: admin-guide/configuration/package_repositories - file: admin-guide/configuration/services diff --git a/admin-guide/configuration.md b/admin-guide/configuration.md index bba8586b..fcf35d12 100644 --- a/admin-guide/configuration.md +++ b/admin-guide/configuration.md @@ -7,6 +7,7 @@ Here starts a so far small collections of configuration guides for sysadmins of ## Software Management - [Package Installation](configuration/packages) +- [Python](configuration/python) - [Automated Package Updates](configuration/package_updates) - [Selecting Package Repositories](configuration/package_repositories) - [Managing Services with Systemd](configuration/services) diff --git a/admin-guide/configuration/packages.md b/admin-guide/configuration/packages.md index be01e574..083bda13 100644 --- a/admin-guide/configuration/packages.md +++ b/admin-guide/configuration/packages.md @@ -30,7 +30,6 @@ base::package_groups: ``` - ## Install a Group of Packages To add a RedHat predefined group of packages (checkout out `dnf grouplist --hidden`) prepend the name of it with a `@`, e.g. for "Java Platform" it would be `@Java Platform`: @@ -81,6 +80,7 @@ The `pip` tag can be used to install Python module using `pip`: base::pkg_group::my_pip_modules: - 'gitinfo:pip' ``` +Note that packages installed with `pip` are not updated automatically. ## Remove Packages diff --git a/admin-guide/configuration/python.md b/admin-guide/configuration/python.md new file mode 100644 index 00000000..ba018afd --- /dev/null +++ b/admin-guide/configuration/python.md @@ -0,0 +1,47 @@ +# 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`](https://docs.python.org/3/library/venv.html) or [Conda](https://docs.conda.io) 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](packages). + +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 +```