Python:什么包包含安装元数据?

时间:2010-04-11 06:01:59

标签: python installation metadata

例如,如何在“/ usr / bin / python”中找到可执行文件,在“/usr/lib/python2.6”中找到库文件?

2 个答案:

答案 0 :(得分: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']

答案 1 :(得分:1)

distutils.sysconfig是“提供对Python的低级配置信息的访问”的模块。特别是get_python_lib函数给出了“通用或平台相关库安装的目录”,具体取决于它的参数。

但是,sys.executable模块未公开sysconfig - 它仅在sys模块中公开。