usage of .pth files

S

swapnil

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['', '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
 
G

Gabriel Genellina

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['', '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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top