CentOS 8 install Python

If we try to run py scripts or software that uses python in CentOS 8, we get one of the following errors:

/usr/bin/python: bad interpreter: No such file or directory
/usr/bin/python2: bad interpreter: No such file or directory
/usr/bin/python3: bad interpreter: No such file or directory

This is due to the fact that in CentOS 8, the python package is not installed by default. The system developers decided to leave the version choice and installation to us users.

CentOS 8 install Python3

On CentOS 8 install python is done with a single command. If we want to install a stable 3rd version (3.6 at the time of writing), from the base repository, execute dnf install python3:

We agree y and press Enter.

CentOS 8 install Python2

To install python2 (2.7), run dnf install python2:

Again, we agree with the installation of the pact and the dependencies.

Remove Python

If you need to remove the python package, you must run one of the following commands, depending on the version: dnf remove python2 or dnf remove python3

Leave a Comment