我怎样才能使用PYTHONPATH?当我尝试在路径中运行脚本时,找不到该文件.当我cd到包含脚本的目录时,脚本运行.那么PYTHONPATH有什么用呢?
$ echo $PYTHONPATH
:/home/randy/lib/python
$ tree -L 1 '/home/randy/lib/python'
/home/randy/lib/python
??? gbmx_html.py
??? gbmx.py
??? __init__.py
??? __pycache__
??? scripts
??? yesno.py
$ python gbmx.py -h
python: can't open file 'gbmx.py': [Errno 2] No such file or directory
$ cd '/home/randy/lib/python'
Run Code Online (Sandbox Code Playgroud)
cd到文件目录后运行..
$ python gbmx.py -h
usage: gbmx.py [-h] [-b]
Run Code Online (Sandbox Code Playgroud)
为什么我不能使用PYTHONPATH?