python查找模块安装路径

记一下,方便以后查询

一、

>>> import pexpect
>>> print pexpect.__file__
/usr/lib/python2.6/site-packages/pexpect.pyc

二、

>>> import os
>>> path = os.path.dirname(pexpect.__file__)
>>> print path
/usr/lib/python2.6/site-packages

Post a Comment