Red Hat Training

A Red Hat training course is available for RHEL 8

Chapter 40. Configuring the unversioned Python

System administrators can configure the unversioned python command, located at /usr/bin/python, using the alternatives command. Note that the required package, python3, python38, python39, or python2, must be installed before configuring the unversioned command to the respective version.

Important

The /usr/bin/python executable is controlled by the alternatives system. Any manual changes may be overwritten upon an update.

Additional Python-related commands, such as pip3, do not have configurable unversioned variants.

40.1. Configuring the unversioned python command directly

You can configure the unversioned python command directly to a selected version of Python.

Prerequisites

  • Ensure that the required version of Python is installed.

Procedure

  • To configure the unversioned python command to Python 3.6, use:

    # alternatives --set python /usr/bin/python3
  • To configure the unversioned python command to Python 3.8, use:

    # alternatives --set python /usr/bin/python3.8
  • To configure the unversioned python command to Python 3.9, use:

    # alternatives --set python /usr/bin/python3.9
  • To configure the unversioned python command to Python 2, use:

    # alternatives --set python /usr/bin/python2

40.2. Configuring the unversioned python command to the required Python version interactively

You can configure the unversioned python command to the required Python version interactively.

Prerequisites

  • Ensure that the required version of Python is installed.

Procedure

  1. To configure the unversioned python command interactively, use:

    # alternatives --config python
  2. Select the required version from the provided list.
  3. To reset this configuration and remove the unversioned python command, use:

    # alternatives --auto python

40.3. Additional resources

  • alternatives(8) and unversioned-python(1) man pages