[Solved] ubuntu /usr/bin/env: python: No such file or directory

I update the kernel, after that the Ubuntu doesn’t work well, PS: I try to exec “meld” command, it will report that “/usr/bin/env: python: No such file or directory”,
then I exec “sudo apt-get install python” and get the result “python is already the newest version.”, what should I do for it.


I’m not good at linux, can you tell me how to revert my linux to the last right status, or reinstall the python normally.

Enquirer: Hao

||
Solution #1:

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
Solution #2:

Having been momentarily stumped by this error myself, I thought I’d 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 python15” where 15 is the invisible CR character… /usr/bin/env was, then, unable to find a command “python15” – 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.

Respondent: aSteve
Solution #3:

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
Respondent: mchid
Solution #4:

@mchid’s answer is the one you should go for it.

just FYI,

if you do this:
$ python

it will say Command 'python' not found ...

But if you do this:
$ python3, it should work.

So, just modify the shebang line

from !#/usr/bin/env python
to !#/usr/bin/env python3, you’re good to go.

(which is automatically done by doing
sudo apt install python-is-python3)

Respondent: starriet
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.