#!/ usr / bin / env不能作为环境

时间:2018-08-17 07:46:24

标签: python macos

我正在MacOS上学习环境

#map_it.py - launches a map in the browser using an address from the command line or clipborad
#!/usr/bin/env python
import webbrowser, sys
if len(sys.argv) > 1:
    #Get the address from the command line
    address = "".join(sys.argv[1:])
    print(address)
#todo:get the address from the clipboard

我将shebang设置为脚本的顶部,该脚本未能按预期工作

$ map_it.py test
-bash: map_it.py: command not found
$ map_it test
-bash: map_it: command not found

#!/usr/bin/env python更改为#!/usr/bin/env python3#!/usr/bin/env之后,
报告相同的错误。

如何修复此类错误?

1 个答案:

答案 0 :(得分:2)

您需要执行以下任一操作:

$ ./map_it.py test

$ python map_it.py test

...否则,您表示该脚本是系统安装的命令。