我正在阅读O'Reilly Learning Python(第4版).有一段名为Unix Executable Scripts(#!)(第46页).
给出的示例如下:
`再次使用文本编辑器创建一个名为brian的Python代码文件:
#!/usr/local/bin/python
print('The Bright Side ' + 'of Life...')
Run Code Online (Sandbox Code Playgroud)
`就像在示例中一样,我将此脚本保存在名为'brian'的文件中(没有.py,因为它不是必需的).
然后我给文件权限 chmod +x brian
然后说我可以从操作系统shell运行它,就好像它是一个二进制程序:
% brian
The Bright Side of Life...
Run Code Online (Sandbox Code Playgroud)
"
但是,当我从命令窗口尝试调用"brian"时,我收到以下错误:
bash: brian: command not found
Run Code Online (Sandbox Code Playgroud)
但是python brian给了我正确的结果.
为什么在示例中调用'brian'对我不起作用?