在shell脚本中运行python命令失败,单独命令行模式可以运行,求大神帮忙看看!

weixin_44737792 2019-05-10 05:26:48
python test001.py 脚本内容如下:

#!/usr/bin/python

print("hellow world run by python!!")
jenkins2937.sh 脚本内容如下:
echo "hahahaha"
python /tmp/test001.py

命令行执行结果成功
swx@ubuntu:/tmp$ python test001.py
hellow world run by python!!
shell执行结果失败
swx@ubuntu:/tmp$ ./jenkins2937.sh
hahahaha
./jenkins2937.sh: line 2: python: command not found
swx@ubuntu:/tmp$
...全文
469 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
一笑程序猴 2019-05-10
  • 打赏
  • 举报
回复
在你的shell脚本中指定一下python的路径试试
看上去应该是python路径的问题,我用windows的cmd命令也遇到过这样的问题,切换到python的安装目录下就可以了

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧