Mik*_*ike 4 python unix solaris python-3.x
我在 Solaris 环境中运行 Python 脚本时遇到以下问题。
看来我在 shebang 线上做了一些不正确的事情,但我无法判断这是 Python 3 问题还是命令行问题。
但我怀疑它与 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
Run Code Online (Sandbox Code Playgroud)
编辑:我可以确认 test.py 中的行结尾是 Unix
编辑2: od输出
$ od -c -N 30 test.py
0000000 # ! / o p t / p y t h o n 3 . 3
0000020 . 2 / b i n / p y t h o n 3
0000036
Run Code Online (Sandbox Code Playgroud)
编辑3: shell是bash
$ echo $0
/bin/bash
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1151 次 |
| 最近记录: |