How to get path to Python standard library directory?

Dave Angel d at davea.name
Fri Nov 25 08:08:08 EST 2011


On 11/25/2011 06:24 AM, user wrote:
> In a Makefile (or sometimes inside python) I need the path to the root 
> of the Python standard lib folder used by "env python".
>
> e.g.  /usr/lib/python2.6/   or    C:\Python27\Lib\
>
> what is the best/canonical way to get that?

You could look at sys.executable.  However, on my Linux, it's a symlink, 
so you have to dereference that to get the directory involved.

-- 

DaveA




More information about the Python-list mailing list