如何在 $PATH 上调用 python 到 运行 脚本
How call python to run script on $PATH
我的 $PATH 环境变量有 /a/path/with spaces/in/it,它上面有一个 python 脚本,我想从不同的位置 运行。
但是当我尝试使用 python3 运行 它时,我收到一个找不到文件的错误。
$ python3 prog.py
python3: can't open file 'prog.py': [Errno 2] No such file or directory
当我尝试对其应用 linux 文件命令时,同样的情况发生了:
$ file prog.py
prog.py: cannot open `prog.py' (No such file or directory)
然而,如果我在同一路径上键入 bash 个脚本的名称,它们会按预期 运行。
同样,如果我只键入 prog.py,我的 shell 会尝试 运行。所以我的系统可以很好地看到文件。
更重要的是,如果我 cd 到 prog.py 的实际位置,然后告诉 python3 到 运行 它,它会按原样执行。
为什么会发生这种情况,或者为什么没有发生这种情况?
以及如何按照我的意愿执行命令?
我的 $PATH 环境变量有 /a/path/with spaces/in/it,它上面有一个 python 脚本,我想从不同的位置 运行。
但是当我尝试使用 python3 运行 它时,我收到一个找不到文件的错误。
$ python3 prog.py
python3: can't open file 'prog.py': [Errno 2] No such file or directory
当我尝试对其应用 linux 文件命令时,同样的情况发生了:
$ file prog.py
prog.py: cannot open `prog.py' (No such file or directory)
然而,如果我在同一路径上键入 bash 个脚本的名称,它们会按预期 运行。
同样,如果我只键入 prog.py,我的 shell 会尝试 运行。所以我的系统可以很好地看到文件。
更重要的是,如果我 cd 到 prog.py 的实际位置,然后告诉 python3 到 运行 它,它会按原样执行。
为什么会发生这种情况,或者为什么没有发生这种情况?
以及如何按照我的意愿执行命令?