Is the order reported by "sys.path" the search order for packages?

Does the order in which the entries in Python sys.path

match the order in which the packages are found? For example, I have

>>> from pprint import pprint     
>>> pprint(sys.path)
['',
 '/Library/Python/2.7/site-packages/ipython-0.14.dev-py2.7.egg',
 '/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg',
 '/Library/Python/2.7/site-packages/numpy-1.8.0.dev_3abd869_20121222-py2.7-macosx-10.8-intel.egg',
 '/Library/Python/2.7/site-packages/pymc-2.2-py2.7-macosx-10.8-intel.egg',
 '/Library/Python/2.7/site-packages/scikit_learn-0.13_git-py2.7-macosx-10.8-intel.egg',
 '/Library/Python/2.7/site-packages/scipy-0.12.0.dev_d631749_20121222-py2.7-macosx-10.8-intel.egg',
 '/Library/Python/2.7/site-packages/statsmodels-0.5.0-py2.7-macosx-10.8-intel.egg',
 '/Library/Python/2.7/site-packages/readline-6.2.4.1-py2.7-macosx-10.7-intel.egg',
 '/Library/Python/2.7/site-packages/nose-1.2.1-py2.7.egg',
 '/Library/Python/2.7/site-packages/six-1.2.0-py2.7.egg',
 '/Library/Python/2.7/site-packages/tornado-2.4.1-py2.7.egg',
 '/Library/Python/2.7/site-packages/pyzmq-2.2.0.1-py2.7-macosx-10.8-intel.egg',
 '/Library/Python/2.7/site-packages/patsy-0.1.0-py2.7.egg',
 '/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg',
 '/Library/Python/2.7/site-packages/xattr-0.6.4-py2.7-macosx-10.8-intel.egg',
 '/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg',
 '/Library/Python/2.7/site-packages/astropy-0.3.dev2837-py2.7-macosx-10.8-intel.egg',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
 '/Library/Python/2.7/site-packages']

      

so, in general, I have

['',
 '/Library/Python/2.7/site-packages/PKG_WITH_EGG.egg',
 ...
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
 ...
 '/Library/Python/2.7/site-packages']

      

Does this mean that if the package I am installing (in "site-packages") has .egg

, it will replace the version of the same package that may be in "Extra", but those site-packages') that do not have .egg

, will be replaced by any version in 'Extras'?

+3
python path package


source to share


No one has answered this question yet

See similar questions:

2
What is the difference between Python's 'Extras' and 'site-packages' directories?
0
What is the design reason for ordering the Python package path?

or similar:

1988
Find the version of the installed npm package
52
What sets sys.path from Python and when?
24
ImportError: No module named xgboost
4
import pymongo works in Python interpreter, but not script
3
Wrong sys.path in jupyter notebook when running in virtual environment
1
python manage.py runningerver No module named django.core.management
1
"ImportError: No module named selenium"
1
Need to put all modules in one folder - 2 sets of Python "Framework" installed on Mac? (System / Library / Frameworks and Library / Frameworks)
0
python27 nose and sklearn
0
Different boot paths in rubypython and python



All Articles
Loading...
X
Show
Funny
Dev
Pics