PYTHONPATH 变量空白
PYTHONPATH variable blank
根据 documentation,sys.path 在 python 会话启动时从 PYTHONPATH 初始化。但是,在我的例子中,PYTHONPATH 变量是空的。当我在终端中执行此操作时:
echo $PYTHONPATH
它returns空白。另一方面,当我开始 python 并检查 sys.path:
import sys
print (sys.path)
我得到了一长串路径。这些是从哪里加载的?我错过了什么?
Check the documentation again:
它说
[sys.path
is initialized] from the environment variable PYTHONPATH
, plus an installation-dependent default.
此外,
the first item of this list, path[0]
, is the directory containing the script that was used to invoke the Python interpreter [… or] the empty string
这就是为什么你的不是空的。
根据 documentation,sys.path 在 python 会话启动时从 PYTHONPATH 初始化。但是,在我的例子中,PYTHONPATH 变量是空的。当我在终端中执行此操作时:
echo $PYTHONPATH
它returns空白。另一方面,当我开始 python 并检查 sys.path:
import sys
print (sys.path)
我得到了一长串路径。这些是从哪里加载的?我错过了什么?
Check the documentation again:
它说
[
sys.path
is initialized] from the environment variablePYTHONPATH
, plus an installation-dependent default.
此外,
the first item of this list,
path[0]
, is the directory containing the script that was used to invoke the Python interpreter [… or] the empty string
这就是为什么你的不是空的。