[python-win32] PYTHONPATH and .pth files under Windows XP

Mark Hammond mhammond at skippinet.com.au
Wed Dec 20 06:15:49 CET 2006

> PYTHONPATH and .pth files under Windows XP
> No matter what my PYTHONPATH is set to as a Enivorment
> Variable under Windows XP, the only time a .pth file is
> actually being read and used is when I dump it into my
> site-packages directory off my install location.

A quick scan of http://docs.python.org/lib/module-site.html shows that
Python doesn't promise to offer the behaviour you desire on any platform.

Check out site.py in the Python Lib directory, specifically
addsitepackages - that is just the code that implements the documented
behaviour, but it will at least give you insights into how you might be able
to exploit it.

An alternative is to have your code do:

  import site

Which should cause any .pth files in your_dir to be picked up.



More information about the Python-win32 mailing list