CentOS 8 does not include a command that responds to python
! Here are some solutions to this!
There are some good reasons why CentOS8 does not include python
(as opposed to python2
or python3
), and I especially like the fact that it makes you ensure you use the appropriate version. For a lengthier discussion, this RedHat blog post goes into details and is worth a read.
However, a lot of programs invoke python with a command like #!/usr/bin/env python
and those break without a python
. There are a couple of solutions depending on your level of access.
If you have root access
I don’t recommend doing this, because it sets a default python for everyone and negates exactly what the developers were trying to accomplish by eliminating the python
command as detailed in the above blog post. However, a system-wide solution is to update-alternatives
via either of these two commands:
update-alternatives --config python
This will provide you with a list of python
commands and you can choose the one that you want to set as appropriate.
or
alternatives --set python /usr/bin/python3
This will explicitly set the version.
Note that you need root access for this, and although supposedly there are approaches to make this work on a per-user basis, I could not get that to work.
If you do not have root
The best way to do this is to create a symlink to a python somewhere in your PATH
environment, especially near the end (since PATH
is processed from left to right), although that probably doesn’t matter.
I put it either in $HOME/bin
or $HOME/opt/bin
depending on exactly how I have things set up:
cd $HOME/bin ln -s /usr/bin/python3 python
this should now give you a working python
command.