ubuntu /usr/bin/env: python: No such file or directory
ubuntu /usr/bin/env: python: No such file or directory
Problem scenario:
/usr/bin/env: ‘python’: No such file or directory
Possible Solution #1
- If Python 3 is not installed, install it:
apt-get install python3
Possible Solution #2
-
If Python 3 has been installed, run these commands:
whereis python3
-
Then we create a symlink to it:
sudo ln -s /usr/bin/python3 /usr/bin/python
Having been momentarily stumped by this error myself, I thought Id post how I fixed my problem.
My problem was an error:
: No such file or directory
Which made little sense to me. My problem is that my editor had silently converted the script from Unix LF to Windows CR/LF line-termination. A rather unfortunate upshot of this is that #!/usr/bin/env python actually became #!/usr/bin/env python 15 where 15 is the invisible CR character… /usr/bin/env was, then, unable to find a command python 15 – hence the file-not-found error.
Converting the script to Unix line-ending convention solved my problem… but only after a few minutes head-scratching.
ubuntu /usr/bin/env: python: No such file or directory
On Ubuntu 20.04 and newer, there is a package to fix this problem. Run the following commands:
sudo apt update
sudo apt install python-is-python3
Run apt-cache show python-is-python3
for more info.