首页 > 代码库 > /usr/bin/env python no such file or directory: dos格式导致的!
/usr/bin/env python no such file or directory: dos格式导致的!
最近修改了几个python文件,发现在linux上只能用python file来执行,直接./file提示错误“no such file or directory”,而脚本是用“#!/usr/bin/env python”开头的,应该是可以直接执行的。
一般情况下,这个错误是由于没有权限导致的。但是这个脚本是有执行权限的。google后发现,原来是格式的问题!之前有几次我把文件ftp到windows上编辑,估计是不小型点了转换格式的按钮。。。手贱啊。。
http://www.gossamer-threads.com/lists/python/python/77314
> When trying to run a script, I get the following message:
/usr/bin/env: python: No such file or directory [In reply to]
>
> /usr/bin/env: python: No such file or directory
Though perhaps not the case here, I‘ll just mention a problem that is
worth being aware of when transferring a script from a Windows/DOS
system to Unix. If the difference in line-ending conventions hasn‘t
been taken care of (such as by using ASCII mode during FTP transfer),
then the spurious ^M in the script‘s #! line can trip up the shell or
the env command, since it will be trying to run the program python^M.
Hamish LawsonPasted from: <http://www.gossamer-threads.com/lists/python/python/77314>
From WizNote
/usr/bin/env python no such file or directory: dos格式导致的!
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。