ubuntu /usr/bin/env: python: No such file or directory
PythonUbuntu 9.04Python Problem Overview
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.
Python Solutions
Solution 1 - Python
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
EDIT: hi everyone, I noticed that @mchid posted a better solution below my answer: sudo apt install python-is-python3
.
Solution 2 - Python
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.
Solution 3 - Python
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 python\015" where \015 is the invisible CR character... /usr/bin/env was, then, unable to find a command "python\015" - 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.
Solution 4 - Python
May 2022: For anyone who just updated to Monterey 12.3 it appears the update replaces python with python3. Downloading python fixes the issues in Xcode and git command line. Be sure to read the two comments below.
Solution 5 - Python
@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
)
Solution 6 - Python
This answer for android build system error For Python 3
If you get a "/usr/bin/env 'python' no such file or directory" error message, use one of the following solutions: If your Ubuntu 20.04.2 LTS is a newly installed (vs. upgraded) Linux version:
sudo ln -s /usr/bin/python3 /usr/bin/python
f using Git version 2.19 or greater, you can specify --partial-clone when performing repo init. This makes use of Git's partial clone capability to only download Git objects when needed, instead of downloading everything. Because using partial clones means that many operations must communicate with the server, use the following if you're a developer and you're using a network with low latency:
repo init -u https://android.googlesource.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M
you can see document in Downloading the Source
Solution 7 - Python
For people facing the same issue with MacOS and installed python3 with homebrew:
sudo ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python