usage of .pth files

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Jan 13 04:31:54 EST 2010


En Wed, 13 Jan 2010 05:01:41 -0300, swapnil <swapnil.st at gmail.com>  
escribió:

> Python's documentation (http://docs.python.org/install/
> index.html#modifying-python-s-search-path) states that we can add more
> locations to python's module search path by
> "add a path configuration file to a directory that’s already on
> Python’s path, usually to the .../site-packages/ directory"
>
> sys.path for my Python installation show the following
>>>> sys.path
> ['', 'C:\\WINNT\\system32\\python26.zip', 'c:\\python26\\DLLs', 'c:\
> \python26\\lib', 'c:\\python26\\lib\\plat-win', 'c:\\python26\\lib\
> \lib-tk', 'c:\\python26', 'c:\\python26\\lib\\site-packages']
>
> I tried appending certain location by putting a .pth file in all of
> the above locations, but it gets appended only when the .pth file is
> present in 'c:\\python26\\lib\\site-packages' or 'c:\\python26', but
> according to the documentation it should work for all of the above
> locations. Any ideas??
>
> I'm running Python 2.6.4 on WinXP

It's a long standing documentation bug - not every directory in sys.path  
is searched for .pth files, only those explicitely added by site.py(see  
http://docs.python.org/library/site.html)
On Windows, those are: the main installation directory (c:\PythonNN  
usually), the site-packages directory (c:\PythonNN\lib\site-packages) and  
the user site directory ("%APPDATA%\Python\PythonNN\site-packages"); for  
the last one see PEP 370.

-- 
Gabriel Genellina




More information about the Python-list mailing list