如何使用 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'
cd 到文件目录后,它运行..
$ python gbmx.py -h
usage: gbmx.py [-h] [-b]
为什么我不能使用 PYTHONPATH?