我在Solaris环境中运行Python脚本时遇到了以下问题。在
似乎我在shebang行上做了一些不正确的事情,但我不能判断这是python3问题还是命令行问题。在
但我怀疑它与shebang行有关,因为当我在命令行上显式运行Python解释器时没有问题。在
路径/opt/python3.3.2/bin/python3.3
是我的系统管理员选择放置Python的位置,我不知道这个位置在Solaris上有什么问题。在
$ uname -a
SunOS ... 5.10 Generic_150401-49 i86pc i386 i86pc Solaris
$ cat test.py
#!/opt/python3.3.2/bin/python3.3
import sys
print("hi")
$ ./test.py
./test.py: line 2: import: command not found
./test.py: line 3: syntax error near unexpected token `"hi"'
./test.py: line 3: `print("hi")'
$ /opt/python3.3.2/bin/python3.3 test.py
hi
编辑:我可以确认测试.py是Unix吗
编辑2:od
输出
编辑3:shell是bash
$ echo $0
/bin/bash
所有重要的事情都发生在评论中。我来总结一下。在
在彻底检查shebang行本身是否正确编写之后,考虑了来自其他系统的一个类似的bug(我知道)。在
事实证明,Solaris受到与讨论和解决的问题相同的影响{a1}。摘要:shebang行要求解释器是二进制的,而不是另一个脚本。在
相关问题 更多 >
编程相关推荐