Python

From Wiki
Jump to navigation Jump to search

python: command not found

If you’re getting "python: command not found" on Almanlinux 9, Python 2 is now end of life and many systems now use Python 3, the python command does not always refer to the correct version of Python. While many systems create an alias for the python command that refers to a specific version of Python, this alias may not point to the correct version of Python for your system.

To work around this issue, you can create a symlink or use alternatives to redirect the /usr/bin/python command to the version of Python installed on your server.

Use alternatives to redirect your python command to Python 3

On AlmaLinux, Rocky Linux, and CloudLinux 9 servers, to use alternatives to redirect the python command to Python 3, run the following command:

alternatives --install /usr/bin/python python /usr/bin/python3 1


Use symlinks to redirect your python command to Python 3

On AlmaLinux, Rocky Linux, Ubuntu, and CloudLinux 9 servers, to create a symlink to redirect the python command to Python 3, run the following command:

ln -s /usr/bin/python3 /usr/bin/python