如何在不使用CD-cd进入目录的情况下在命令行中使用Python脚本?是PYTHONPATH吗?
发布于 2021-02-02 23:16:31
如何使用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?
关注者
0
被浏览
76
1 个回答