System default sys.path

David Lyon david.lyon at
Thu Jul 2 06:40:25 CEST 2009

On Wed, 01 Jul 2009 19:48:04 -0700, Brock Pytlik <bpytlik at Sun.COM> wrote:
> Hi, I'm trying to find a way to get the value sys.path would have on a 
> particular system if python was started with an empty python path. I do 
> want it to include the site specific additional paths. I know I can hack 
> this information myself, 

Copy the code out from

> but I'd rather be able to get this on demand so 
> that if things change in the future, I don't have grovel around looking 
> for which directory string to change.

            for index in range(len(sys.path)):
                del sys.path[0]

> If nothing else, I think the following would satisfy my needs:
> 1) a variable containing the directories to use as a prefix (I think 
> sys.exec_prefix and sys.prefix are what I want here)
> 2) a variable containing the list of suffixes that are applies to the 
> prefixes, like lib/python<version>/site-packages
> 3) a way of handing the *.pth files

What way do you want to handle them?

More information about the Python-list mailing list