运行 终端中的 python 脚本

Run a python script in terminal

我正在尝试 运行 在终端 hello.py python 脚本中:

#! usr/bin/env python3  
print("Hello", "World!")

在终端中调用以下命令时(在 hello.py 所在的工作目录中):

$ chmod +x hello.py
$ ./hello.py

我得到:

bash: ./hello.py: usr/bin/env: bad interpreter: No such file or directory

我无法超越它。我在终端检查了以下内容 (可能需要进一步说明):

_____________________________________________________________________
$ python3
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.executable)
/usr/bin/python3
_____________________________________________________________________
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
_____________________________________________________________________
$ which python3
/usr/bin/python3
_____________________________________________________________________

感谢您的澄清!

很简单,你忘了给绝对路径

使用#!/usr/bin/env python3