sh: 1: python: not found on Ubuntu 20.04 LTS

· 1 min read
sh: 1: python: not found on Ubuntu 20.04 LTS
Photo by Riku Lu / Unsplash

This error means Python is either not installed or your installation damaged including wrong $PATH settings.. Here is how you can solve this problem.

Type any one of the following commands to see if python binary exists on a Linux:

type python
type python2 # is it python version 2?
type pytho3 # how about python version 3?
command -v python
type -a python

If Python is missing for an unknown reason or was not installed by my cloud provider to save the disk space. So install it.

sudo apt-get install python3

Make sure symlink support is installed too on Ubuntu Linux version 20.04 LTS and above, type:

sudo apt install python-is-python3

Once installed you can view python and its version easily using any one of the following commands:

type -a python
which python
ls -l /usr/bin/python
ls -l /usr/bin/python*
ls -l /usr/local/bin/python*
# Make sure /usr/bin and /usr/local/bin are in PATH variable #
echo "$PATH"