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

Diez B. Roggisch deets at nospam.web.de
Sun Jan 20 13:50:44 EST 2008


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?

Diez



More information about the Python-list mailing list