如何使用PYTHONPATH?当我尝试在路径中运行脚本时,找不到文件。当我进入包含该脚本的目录时,该脚本将运行。那么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?
PYTHONPATH
PYTHONPATH
。