本文介绍了Python的sys.path是从哪里初始化的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Python的sys.path是从哪里初始化的?
Where is Python's sys.path initialized from?
UPD :Python在引用PYTHONPATH之前添加了一些路径:
UPD: Python is adding some paths before refering to PYTHONPATH:
>>> import sys
>>> from pprint import pprint as p
>>> p(sys.path)
['',
'C:\\Python25\\lib\\site-packages\\setuptools-0.6c9-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\orbited-0.7.8-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\morbid-0.8.6.1-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\demjson-1.4-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\stomper-0.2.2-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\uuid-1.30-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\stompservice-0.1.0-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\cherrypy-3.0.1-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\pyorbited-0.2.2-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\flup-1.0.1-py2.5.egg',
'C:\\Python25\\lib\\site-packages\\wsgilog-0.1-py2.5.egg',
'c:\\testdir',
'C:\\Windows\\system32\\python25.zip',
'C:\\Python25\\DLLs',
'C:\\Python25\\lib',
'C:\\Python25\\lib\\plat-win',
'C:\\Python25\\lib\\lib-tk',
'C:\\Python25',
'C:\\Python25\\lib\\site-packages',
'C:\\Python25\\lib\\site-packages\\PIL',
'C:\\Python25\\lib\\site-packages\\win32',
'C:\\Python25\\lib\\site-packages\\win32\\lib',
'C:\\Python25\\lib\\site-packages\\Pythonwin']
我的PYTHONPATH是:
My PYTHONPATH is:
PYTHONPATH=c:\testdir
我想知道PYTHONPATH之前的那些路径是哪里来的吗?
I wonder where those paths before PYTHONPATH's ones come from?
推荐答案
从环境变量PYTHONPATH初始化,加上与安装有关的默认值"
"Initialized from the environment variable PYTHONPATH, plus an installation-dependent default"
- http://docs.python.org/library/sys. html#sys.path
这篇关于Python的sys.path是从哪里初始化的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!