今天在电脑上写了一个Python脚本,写好之后用ftp传上去,然后执行/var/www/cron.py,结果报错,/bin/usr/python: bad interpreter: No such file or directory,之前都是执行python /var/www/cron.py都没问题啊,看来应该不是代码的问题。

上网上搜了一下,有很多人都反映在windows下写的python文件会由于编码问题执行出错(windows下的换行符是'\r',而linux下是'\n'),于是检查了一下cron.py,用vim打开,然后用命令模式输入"set ff",结果输出”filefomat=DOS“,果真是这里的问题,于是执行set ff=unix,设置成linux下的文件编码,wq保存,再重新执行/var/www/cron.py,Ok正常了。

有时候可能不一定是这个问题,有可能是python解释器的路径的问题,这个要看安装Python的时候有没有将/usr/bin/python链接到对应的Python版本上,来到”/bin/usr/“路径下,”ls python“,嗯,没问题,不过显示python只是一个符号链接,”ls -l python“,输出:

lrwxrwxrwx 1 root root 9 2010-07-08 12:35 python -> python2.7

解决办法是,将”#!/usr/bin/python“修改为”#!/usr/bin/python2.7“,然后重新执行python脚本,一般就可以了,建议写成/usr/bin/env python,这样就会自动查找python版本对应的路径。

执行Python "/bin/usr/python: bad interpreter: No such file or directory" 错误的更多相关文章

  1. -bash: ./start.sh: /bin/sh^M: bad interpreter: No such file or directory 错误解决方案

    问题描述:sh文件中,在win环境下,用WinSCP编辑,出现如下错误: -bash: ./start.sh: /bin/sh^M: bad interpreter: No such file or ...

  2. bash: /bin/bash^M: bad interpreter: No such file or directory

    在windows下编写shell脚本在linux下运行会出报错: [hadoop@master data]$ ./load_ods_table.sh -bash: ./load_ods_table.s ...

  3. nagios监控客户端报错/usr/bin/perl^M: bad interpreter: No such file or directory

    nagios服务端监控客户端内存时发现监控不上 在客户端直接执行脚本,报错如下: # /usr/local/nagios/libexec/check_memory.pl -w 6% -c 3% -ba ...

  4. windows系统编辑过的脚本文件,在linxu上执行报错 /bin/sh^M: bad interpreter: No such file or directory

    如题! 现象: 当时的场景是这样的:我在IDEA中编辑了项目中的脚本sh,然后利用maven打成zip包.把zip包上传到linux服务器解压运行. 当在linux服务器上运行该sh脚本文件时,提示错 ...

  5. sh脚本异常:/bin/sh^M:bad interpreter: No such file or directory

    在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory. 分析:这是不同系统编码格式引起的:在windows系统中 ...

  6. -bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory

    刚刚学习SHELL 写了一个简单的例子发生如下错误 -bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory ...

  7. /bin/bash^M: bad interpreter: No such file or directory

    <今天遇到的问题,  网上有非常多类似的文章,  个人记录下来,  加深记忆,  已经明确的就绕路吧.> 运行一个脚本full_build.sh 时, 一直是提示我: -bash: ./f ...

  8. Shell脚本报错:-bash: ./switch.sh: /bin/bash^M: bad interpreter: No such file or directory

    在学习shell中测试case参数命令代码如下 #!/bin/bash #switch测试 case $1 in     start)         echo 'start'     ;;      ...

  9. -bash: ./switch.sh: /bin/bash^M: bad interpreter: No such file or directory

    问题: 偶然使用 windows 进行编写脚本.使用 wsl (windows subsystem for linux) 进行运行的时候,什么事情没有.但是当把脚本移植到远程服务器进行运行的时候,发现 ...

  10. 【转】/bin/bash^M: bad interpreter: No such file or directory

    执行一个脚本full_build.sh 时, 一直是提示我: -bash: ./full_build.sh: /bin/bash^M: bad interpreter: No such file or ...

随机推荐

  1. Sql server 备份还原后出现“受限制用户”问题

    http://jingyan.baidu.com/article/eb9f7b6dcbf1ea869264e856.html SQL数据库作备份和还原操作几乎是日常性事务了.但某次在对Sql Serv ...

  2. [nginx] connect() failed (111: Connection refused) while connecting to upstream, client: 101.18.123.107, server: localhost,

    nginx一直报错, 2016/12/02 10:23:19 [error] 1472#0: *31 connect() failed (111: Connection refused)while c ...

  3. oracle for循环查找结果

    -- Call the procedure begin ' ) loop dbms_output.put_line('v_rlt = '||v_rlt.ID||v_rlt.inspection_no) ...

  4. linux shell:nginx日志切割脚本

    需求原因:nginx不具备日志切割功能,日志量较大,方便分析. 实现目的:完成nginx日志切割,并根据时间命名   简要命令: mv /usr/local/tengine/logs/access.l ...

  5. 前端 动态表单提交(post、put)

    第一步:form表单定义统一属性 <input type="text" class="form-value" /> 第二步:获取所有值 var fo ...

  6. MyBatis入门学习教程-Mybatis3.x与Spring4.x整合

    一.搭建开发环境 1.1.使用Maven创建Web项目 执行如下命令: mvn archetype:create -DgroupId=me.gacl -DartifactId=spring4-myba ...

  7. python---tuple元祖

    ython的元组与列表类似,不同之处在于元组的元素不能修改. 元组使用小括号,列表使用方括号. 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可. tup1 = ('physics', 'c ...

  8. BaiduTemplate模板引擎使用示例附源码

    1.新建项目,asp.net 空Web应用程序 添加data,js,styles,templates文件夹,添加baiduTemplate.js,jquery.js,bootstrap.css 2.添 ...

  9. some notes about spring aop

    1 . timeCountIntecetor implements handlerInterceptor { preHandle(); postHandle(); afterComplete(); } ...

  10. html中空格转义字符

    记录一下,空格的转义字符分为如下几种: 平时一般用的是  1.  &160#;不断行的空白(1个字符宽度) 2.  &8194#;半个空白(1个字符宽度) 3.  &8195# ...