【发布时间】:2013-11-23 21:53:37
【问题描述】:
如何使用 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?
【问题讨论】:
-
我们可以更改这篇文章的标题吗?它实际上并没有要求对
PYTHONPATH进行解释。 -
编辑标题,因为这是在谷歌搜索
PYTHONPATH时出现的第一件事