Comment puis-je utiliser PYTHONPATH? Lorsque j'essaie d'exécuter un script dans le chemin, le fichier n'est pas trouvé. Lorsque je cd dans le répertoire contenant le script, le script s'exécute. Alors à quoi sert le 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'
Après le cd dans le répertoire de fichiers, il s'exécute.
$ python gbmx.py -h
usage: gbmx.py [-h] [-b]
Pourquoi ne puis-je pas utiliser le PYTHONPATH?
PYTHONPATH
PYTHONPATH
.