PYTHONPATH variable blank

て烟熏妆下的殇ゞ 提交于 2019-12-11 07:36:38

问题


According to documentation, sys.path is initialized from PYTHONPATH when python session starts. However, in my case, PYTHONPATH variable is empty. When I execute this in terminal:

echo $PYTHONPATH

it returns blank. On the other hand, when I start python and inspect sys.path:

import sys
print (sys.path)

I get back a long list of paths. Where do those get loaded from? What am I missing?


回答1:


Check the documentation again:

It says

[sys.path is initialized] from the environment variable PYTHONPATH, plus an installation-dependent default.

And furthermore,

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

That’s why yours isn’t empty.



来源:https://stackoverflow.com/questions/48599467/pythonpath-variable-blank

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!