from setuptools.command.easy_install import easy_installclass easy_install_default(easy_install):""" class easy_install had problems with the fist parameter not beingan instance of Distribution, even though it was. This is due tosome import-related mess."""
def __init__(self):from distutils.dist import Distributiondist = Distribution()self.distribution = distself.initialize_options()self._dry_run = Noneself.verbose = dist.verboseself.force = Noneself.help = 0self.finalized = 0
e = easy_install_default()import distutils.errorstry:e.finalize_options()except distutils.errors.DistutilsError:pass
print e.install_dir
Type: moduleString form: <module 'imaplib' from '/usr/lib/python2.7/imaplib.py'>File: /usr/lib/python2.7/imaplib.pyDocstring:IMAP4 client.
Based on RFC 2060.
Public class: IMAP4Public variable: DebugPublic functions: Internaldate2tupleInt2APParseFlagsTime2Internaldate
import site
def get_site_packages_dir():return [p for p in site.getsitepackages()if p.endswith(("site-packages", "dist-packages"))][0]
get_site_packages_dir()# '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages'
如果您想使用终端检索结果:
python3 -c "import site;print([p for p in site.getsitepackages() if p.endswith(('site-packages', 'dist-packages')) ][0])"
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages