How Do You Resolve the “env: ‘python’: No such file or directory” Error without Installing Python 2?

Problem scenario
The security team for your enterprise will not permit Python 2 to be installed. (You do not want to install a new minimal Python package either.) How do you fix the problem of env: ‘python’: No such file or directory when you run a make command?

Solution
The command "python" (not python3), will work after you run this script. Run this script as sudo (e.g., sudo bash /tmp/scriptbelow.sh):

if [ -f "/usr/bin/python" ]
then
  echo "Python has been installed."
else
  pysource=$(which python)
  ln -s $pysource /usr/bin/python
fi

Leave a comment

Your email address will not be published. Required fields are marked *