且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在没有 python 命令的终端中运行 python 脚本

更新时间:2023-01-15 22:36:09

您使用 shebang line 在脚本的开头:

You use a shebang line at the start of your script:

#!/usr/bin/env python

使文件可执行:

chmod +x arbitraryname

并将其放在 PATH 上的目录中(可以是符号链接):

and put it in a directory on your PATH (can be a symlink):

cd ~/bin/
ln -s ~/some/path/to/myscript/arbitraryname