I suggest not to rely on the raw PYTHONPATH because it can vary depending on the OS.
Instead of the PYTHONPATH value in the os.environ
dict, use sys.path
from the sys
module. This is preferrrable, because it is platform independent:
import sys
print(sys.path)
The value of sys.path
is initialized from the environment variable PYTHONPATH, plus an installation-dependent default (depending on your OS). For more info see
https://docs.python.org/2/library/sys.html#sys.path
https://docs.python.org/3/library/sys.html#sys.path
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…