Linux上运行python出现错误“/usr/bin/env: python3: No such file or directory"

If you see the error “: No such file or directory” (with nothing before the colon), it means that your shebang line has a carriage return at the end, presumably because it was edited under Windows (which uses CR,LF as a line separator). The CR character causes the cursor to move back to the beginning of the line after the shell prints the beginning of the message and so you only get to see the part after CR which ends the interpreter string that‘s part of the error message.

Remove the CR: the shebang line needs to have a Unix line ending (linefeed only). Python itself allows CRLF line endings, so the CR characters on other lines don‘t hurt. Shell scripts on the other hand must be free of CR characters.

To remove the Windows line endings, you can use dos2unix:

sudo dos2unix /usr/local/bin/casperjs (你的文件)

or sed:

sudo sed -i -e ‘s/\r$//‘ /usr/local/bin/casperjs (你的文件)

If you must edit scripts under Windows, use an editor that copes with Unix line endings (i.e. something less brain-dead than Notepad) and make sure that it‘s configured to write Unix line endings (i.e. LF only) when editing a Unix file.

原文地址:https://www.cnblogs.com/andy-0212/p/9999750.html

时间: 2024-08-03 21:06:25

Linux上运行python出现错误“/usr/bin/env: python3: No such file or directory"的相关文章

Cannot install NodeJs: /usr/bin/env: node: No such file or directory

安装doxmate时,doxmate地址是:https://github.com/JacksonTian/doxmatenpm install doxmate -g 安装完后把错误:Cannot install NodeJs: /usr/bin/env: node: No such file or directory 解决方法:ln -s /usr/bin/nodejs /usr/bin/node或者sudo apt-get install nodejs-legacy 地址是:http://st

Linux_新手上路_/usr/bin/env: escript:No such file or directory问题

通过make编译mochiweb项目出现了/usr/bin/env: escript:No such file or directory问题. 由于escrpt是erlang的一种高级特性,于是想到是否erlang安装不成功? 重装了几次erlang并没有发现什么异常. 于是去到erlang的安装目录下查找escript的解析器,结果他是存在的且/usr/bin/env也是存在的,但在命令行下去找不到这个命令. 查看系统默认安装目录/usr/local/bin/发现只有erl, wx-confi

ubuntu 执行Python脚本出现: /usr/bin/env: ‘python\r’: No such file or directory

原因: #!/usr/bin/env python 在ubuntu会变成 #!/usr/bin/env python\r 而\r 会被shell 当成参数 所以出现:  /usr/bin/env: 'python\r': No such file or directory 解决方法: vi 此文件 输入:set  ff=unix 再输入:wq 保存 运行成功. 原文地址:https://www.cnblogs.com/AlfredZKY/p/10122643.html

执行yiic出现错误 /usr/bin/env: php: 没有那个文件或目录

开发环境用的是:linux系统+xampp安装包,导入 yii框架后,执行 yiic 命令时,提示:/usr/bin/env: php: 没有那个文件或目录. 解决方法:yiic是使用php脚本创建webapp的,启动yiic到时候,它会自动到/usr/bin/路径下找php执行文件.但是xampp默认安装在 /opt 目录下. 此时我们修改 yiic 文件即可,如下:

呵呵!手把手带你在 IIS 上运行 Python(转)

原文:http://blog.csdn.net/yangzhencheng_001/article/details/40342449 公司的网站让我头痛死了.在众多前辈高手的带领下,一大堆的 CMD 在网站里运行得好好地,黑客攻击也好好地,只有网站和我不好好地,我快累死了,网站快挂了... 为了解决这个问题,我想到了 Python 来解决.可是网站上如何运行 Python.我在网上找了很多资料.结果,互相抄来抄去的,问题层出不穷——各种问题都在我眼前显现.在我不断地瞎折腾,经理在边上不断地看我发

#!/usr/bin/env python 是什么意思

这个在unix类的操作系统才有意义. #!/usr/bin/python是告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器: #!/usr/bin/env python这种用法是为了防止操作系统用户没有将python装在默认的/usr/bin路径里.当系统看到这一行的时候,首先会到env设置里查找python的安装路径,再调用对应路径下的解释器程序完成操作. 加上 #!/usr/bin/env python, 这个py就处于了可执行模式下, (当然是针对linux类的操

Python程序中首行#!/usr/bin/env python的作用

1.通常我们在pycharm中写程序的时候会在首行写上#!/usr/bin/env python 如: #!/usr/bin/env python3#-*-coding: UTF-8 -*-#Author xiaoxingprint ("Hello world!") p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "PingFang SC"; color: #000000 } span.s1 { } span

Python——#!/usr/bin/env python与#!/usr/bin/python的区别——转载

转载自:http://blog.csdn.net/wh_19910525/article/details/8040494 作者:wh_19910525 脚本语言的第一行,目的就是指出,你想要你的这个文件中的代码用什么可执行程序去运行它,就这么简单 #!/usr/bin/python是告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器:#!/usr/bin/env python这种用法是为了防止操作系统用户没有将python装在默认的/usr/bin路径里.当系统看到这一行

#!/usr/bin/env python与#!/usr/bin/python的区别

[摘自:http://blog.csdn.net/wh_19910525/article/details/8040494] 一般的python文件的开头都有#!/usr/bin/python.这是什么意思呢? #!/usr/bin/Python是告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器:#!/usr/bin/env python这种用法是为了防止操作系统用户没有将python装在默认的/usr/bin路径里.当系统看到这一行的时候,首先会到env设置里查找pyt