Ubuntu Python Shebang行不起作用 [英] Ubuntu Python shebang line not working

查看:59
本文介绍了Ubuntu Python Shebang行不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法使shebang行在Ubuntu中使用python脚本.每次我只收到一个未找到命令的错误.

Unable to get shebang line working in Ubuntu for python script. I only get a command not found error each time.

test.py

#!/usr/bin/env python

print ('!')

Ran

:which python
/usr/bin/python

在shebang中使用不同的Python位置玩耍,但是没有运气,包括哪个python提供了什么.有关如何解决此问题的任何提示?

Played around with different locations for python in the shebang but no luck including what was provided by which python. Any tips on how to troubleshoot this?

谢谢

推荐答案

如果您尝试以

$ test.py

该错误可能与shebang无关.而是,test.py所在的目录不在您的 PATH 中.试试

the error may not have anything to do with the shebang. Rather, the directory that test.py resides in is not in your PATH. Try

$ ./test.py

绕过 PATH 查找.

(这是确保脚本本身可执行的补充.)

(This is in addition to making sure that the script itself is executable.)

这篇关于Ubuntu Python Shebang行不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆