ubuntu /usr/bin/env: python: 没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3655306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ubuntu /usr/bin/env: python: No such file or directory
提问by Hao
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.
我更新内核,之后Ubuntu不能正常工作,PS:我尝试执行“meld”命令,它会报告“/usr/bin/env: python: No such file or directory”,然后我执行“sudo apt-get install python”并得到结果“python已经是最新版本。”,我该怎么办。
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.
我不擅长linux,你能告诉我如何将我的linux恢复到最后正确的状态,或者正常重新安装python。
回答by aSteve
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.
这对我来说毫无意义。我的问题是我的编辑器悄悄地将脚本从 Unix LF 转换为 Windows CR/LF 行终止符。一个相当不幸的结果是 "#!/usr/bin/env python" 实际上变成了 "#!/usr/bin/env python\015" 其中 \015 是不可见的 CR 字符... /usr/bin/然后,env 无法找到命令“python\015”——因此出现文件未找到错误。
Converting the script to Unix line-ending convention solved my problem... but only after a few minutes' head-scratching.
将脚本转换为 Unix 行结束约定解决了我的问题......但只是在几分钟的头疼之后。
回答by Francesco Mantovani
Problem scenario:
问题场景:
/usr/bin/env: ‘python': No such file or directory
Possible Solution #1
可能的解决方案 #1
If Python 3 is not installed, install it: apt-get install python3
如果未安装 Python 3,请安装它: apt-get install python3
Possible Solution #2
可能的解决方案#2
If Python 3 has been installed, run these commands: whereis python3
如果已安装 Python 3,请运行以下命令: whereis python3
Then we create a symlink to it: sudo ln -s /usr/bin/python3 /usr/bin/python
然后我们为它创建一个符号链接: sudo ln -s /usr/bin/python3 /usr/bin/python

