2010-04-11 92 views

回答

1

distutils.sysconfig是,「提供訪問Python的低級別的配置信息」模塊。特別是,get_python_lib函數根據其參數給出「用於常規或平臺相關庫安裝的目錄」。

但是,sys.executable未被所述sysconfig模塊公開 - 它僅在sys模塊中。

+0

謝謝亞歷克斯!它看起來像get_python_lib(1,1)就是我所需要的。使用默認參數調用會返回site_packages目錄。 – 2010-04-11 06:50:45

1

你想要sys模塊:

>>> print sys.executable 
/usr/bin/python 
>>> print sys.path 
['', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', 
'/Library/Python/2.6/site-packages', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode'] 
+0

不完全...我正在尋找安裝程序安裝系統庫的位置,而不是路徑上的系統庫。 – 2010-04-11 06:59:44