Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

pythonewbie eproust at gmail.com
Sun Jan 20 17:49:21 EST 2008


On 20 jan, 23:19, "Martin v. Löwis" <mar... at v.loewis.de> wrote:
> > But for different reasons I also want to get the absolute path of
> > Python install directory (not only the executable under Linux) and
> > site-packages directory.
>
> The Python install directory is available as sys.prefix. The
> site-packages directory is
> sys.prefix+"lib/python"+x.y+"/site-packages (where x.y is from
> sys.version_info).
>
> HTH,
> Martin

http://forum.ubuntu-fr.org/viewtopic.php?id=184199

>>> import distutils.sysconfig
>>> distutils.sysconfig.get_python_lib()
'/usr/lib/python2.5/site-packages'

get_python_lib(plat_specific=0, standard_lib=0, prefix=None)
        Return the directory containing the Python library (standard
or
        site additions).

        If 'plat_specific' is true, return the directory containing
        platform-specific modules, i.e. any module from a non-pure-
Python
        module distribution; otherwise, return the platform-shared
library
        directory.  If 'standard_lib' is true, return the directory
        containing standard Python library modules; otherwise, return
the
        directory for site-specific modules.

        If 'prefix' is supplied, use it instead of sys.prefix or
        sys.exec_prefix -- i.e., ignore 'plat_specific'.



More information about the Python-list mailing list