【发布时间】:2018-04-28 20:41:29
【问题描述】:
在 linux 环境下运行名为shuf-new.py 的文件时,当我使用 python 2 时,以下命令有效:
./shuf.py -e bob
但是,当我将代码的第一行更改为 #!/usr/bin/python3 时,出现以下错误:
-bash: ./shuf-new.py: /usr/bin/python3: bad interpreter: No such file or directory
我不知道如何解决这个问题。
【问题讨论】:
-
你确定你已经安装了python3?尝试运行
which python3,如果找到它,请将/usr/bin/python3替换为那个或/usr/bin/env python3 -
#!/usr/bin/env python3是 Unix 系统上推荐的标准 shebang。如果您想强制指定一个特定的 Python 解释器,而不是通过键入python3在命令行中获得的同一个解释器,那么您应该跳过env并使用该解释器的路径。但是你不想在这里,因为你甚至不知道任何特定解释器的路径是什么(并且不需要知道或关心)。 -
请避免多次询问同一个问题。 How to convert turn a python file into a shell script 的可能重复项
标签: python linux bash python-3.x shell