我正在使用Ubuntu服务器而我的路径是:
root@xxx:~# echo $PATH
/usr/local/rvm/gems/ruby-2.2.4/bin:/usr/local/rvm/gems/ruby-2.2.4@global/bin:/usr/local/rvm/rubies/ruby-2.2.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/rvm/bin
请注意/usr/local/bin
是 PATH 的一部分。
我在/usr/local/bin
中有一些程序:
root@xxx:~# ls -la /usr/local/bin
total 152
drwxr-xr-x 2 root root 4096 Dec 23 14:33 .
drwxr-xr-x 11 root root 4096 Dec 24 06:30 ..
-rwxr-xr-x 1 root root 15757 Dec 23 14:32 bypygui.pyw
-rwxr-xr-x 1 root root 123133 Dec 23 14:32 bypy.py
-rwxr-xr-x 1 root root 331 Dec 23 14:33 youtube-dl
root@xxx:~#
由于/usr/local/bin
在PATH中,我可以在其中执行程序:
root@xxx:~# youtube-dl
Usage: youtube-dl [OPTIONS] URL [URL...]
youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.
root@xxx:~#
但是,我无法执行python脚本:
root@xxx:~# bypy.py
: No such file or directory
root@xxx:~# python bypy.py
python: can't open file 'bypy.py': [Errno 2] No such file or directory
root@xxx:~#
在这种情况下,如何从我喜欢的任何地方执行python脚本?