2 Installing Python

To install Python 3.9 on an Oracle Linux 9 system:

sudo dnf install python3

The python3 command points to Python 3.9 if it's installed on the system. To verify that behavior, run the following command:

python3 --version

To optionally enable the unversioned python command, install the python-unversioned-command package:

sudo dnf install /usr/bin/python

In Oracle Linux 9, all unversioned Python commands point to Python 3.9 and can't be configured to run on newer Python versions by using the alternatives command.

Note:

Python 3.9 is supported for the full lifespan of Oracle Linux 9.

Application Stream packages, such as more recent versions of Python 3, have their own major version releases and have shorter support lifespans. For more information, see Oracle Linux: Product Life Cycle Information.

If the system is running Oracle Linux 9.2 or later, you can optionally also install Python 3.11:

sudo dnf install python3.11

The python3 command is aliased to Python 3.9, so for newer versions of Python 3 you need to explicitly reference the correct binary. For example, the following command verifies that Python 3.11 is installed on the system:

python3.11 --version

Installing Extra Python Libraries

You can also install extra dependencies from the Oracle Linux yum server. For example, to install the requests library for the default runtime version of Python 3, you would install the python3-requests package:

sudo dnf install python3-requests

To install dependency packages for specific Python versions, add the runtime version to the package name. For example, to install the requests library for Python 3.11, run the following command:

sudo dnf install python3.11-requests

Dependencies that are installed in this way are available for any compatible Python installations on the same system. In addition, any matching packages can also be removed without also removing existing Python installations.