On 20 jan, 19:50, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > pythonewbie schrieb: > > > > > On 20 jan, 12:20, Christian Heimes <[EMAIL PROTECTED]> 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? > > Diez
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 sys.path. I explain, for Win32, I find install directory using sys.path[6] and site-package directory using sys.path[7], for Linux I find install directory using sys.path[2] and site-package directory using sys.path[6]. 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 advices. -- http://mail.python.org/mailman/listinfo/python-list