Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
eproust at gmail.com
Sun Jan 20 20:37:52 CET 2008
On 20 jan, 19:50, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> pythonewbie schrieb:
> > On 20 jan, 12:20, Christian Heimes <li... at cheimes.de> wrote:
> >> pythonewbie wrote:
> >>> I am stucked on creating a function to get the Python install
> >>> directory (and site-packages directory) with a 100% reliable method...
> >> Only one method is 100% reliable:
> >> try:
> >> import yourextension
> >> except ImportError:
> >> available = False
> >> else:
> >> available = True
> >> Christian
> > Hi Christian,
> > OK thanks, interesting to detect if an extension is available or not.
> > 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.
> > How could I proceed ?
> Maybe sys.path is a starter?
Yes, it is, but my problem is that I am not sure to find the
information I need at the same position of the list generated by
I explain, for Win32, I find install directory using sys.path and
site-package directory using sys.path, for Linux I find install
directory using sys.path and site-package directory using
For my tests, I have used XP Pro and Ubuntu Gutsy.
I am not sure to find these information at the same position in the
sys.path list using Win9x, Win2k, Ubuntu Dapper, Redhat FC6, FreeBSD
and using Python v2.1 2.2 2.3 etc ?
This why I'm asking experienced programmers of this usenet group for
More information about the Python-list