2 Installing Python
To install Python 3.6 on an Oracle Linux 8 system:
sudo dnf install python3
The python3
command points to Python 3.6 if it's installed on the system.
To verify that behavior, run the following command:
python3 --version
The python
command isn't aliased by default in Oracle Linux
8. Specify the Python interpreter version with the python3
command when you
run Python scripts.
If you need to alias the python
command to fix compatibility
problems with existing scripts and applications, you can set it manually. For example, to set
Python 3 as the default interpreter version, run the following command:
sudo alternatives --set python /usr/bin/python3
For more information about using the python
command, see the python(1)
manual page.
Note:
Python 3.6 is maintained for the full lifespan of Oracle Linux 8.
Application Stream packages, such as Python 2.7 and more recent versions of Python 3, have their own major version releases and have shorter maintenance lifespans. For more information, see Oracle Linux: Product Life Cycle Information.
If the system is running Oracle Linux 8.8 or later, you can optionally also install Python 3.11:
sudo dnf install python3.11
If the system is running Oracle Linux 8.10 or later, you can optionally also install Python 3.12:
sudo dnf install python3.12
The python3
command is aliased to Python 3.6 by
default, so for newer versions of Python 3 you must
explicitly reference the correct binary. For example, the following command verifies that
Python 3.12 is installed on the system:
python3.12 --version
Or you can edit the default Python 3 version by using the
alternatives
command. For example, to remap the python3
command to use Python 3.12, run the following command:
sudo alternatives --set python3 /usr/bin/python3.12
Don't uninstall Python 3.6 after making that change, as the command must be reverted when the newer version of Python 3 reaches the end of its maintenance lifespan. Keeping Python 3.6 in place also ensures that the command can be reverted to troubleshoot or resolve problems with systems and components in Oracle Linux 8 that were tested against Python 3.6.
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.12,
run the following command:
sudo dnf install python3.12-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.