Recently while working we got an error: /usr/bin/env: ‘python’: No such file or directory — python is python3. We face this issue on Debian 11/Ubuntu 20.04 or later releases.
For the above-mentioned releases, packages don’t use /usr/bin/python any more. Instead, Python2 and Python3 interpreters are used.
So, for most cases, we can use a symlink that can point /usr/bin/python to a Python3 interpreter. And, the best way to get this done is through the package: python-is-python3
We cover its installation steps next.
Note: Following operations require Administrative rights. If you don’t have the required rights then, contact your System Administrator for assistance.
Install python-is-python3 in Ubuntu
The package is a part of the standard Ubuntu repository. Therefore, we need to update that first. If we install packages without updating the repository then, it may result in the installation of the outdated packages. Therefore, open a terminal:
sudo apt update
Next, install the python-is-python3 package:
sudo apt install python-is-python3
Now, try running the package/program again. This time around it should work.
In conclusion, we have covered here how to fix the issue: [/usr/bin/env: ‘python’: No such file or directory — python is python3]
We can also symlink /usr/bin/python-config to Python3 or Python2 interpreter. Use the package: python-dev-is-python3
Installation steps remain the same: update the repository and install the package.
sudo apt update sudo apt install python-dev-is-python3