Understanding .pth in site-packages

Philip Semanchuk philip at semanchuk.com
Sat Aug 27 20:07:02 CEST 2011

On Aug 27, 2011, at 1:57 PM, Josh English wrote:

> Philip,
> Yes, the proper path should be c:\dev\XmlDB, which has the setup.py, xmldb subfolder, the docs subfolder, and example subfolder, and the other text files proscribed by the package development folder.
> I could only get it to work, though, by renaming the xmldb folder in the site-packages directory, and deleting the egg file created in the site-packages directory. 
> Why the egg file, which doesn't list any paths, would interfere I do not know.
> But with those changes, the xmldb.pth file is being read.
> So I think the preferred search order is:
> 1. a folder in the site-packages directory
> 2. an Egg file (still unsure why)
> 3. A .pth file

That might be implementation-dependent or it might even come down to something as simple as the in which order the operating system returns files/directories when asked for a listing. In other words, unless you can find something in the documentation (or Python's import implementation) that confirms your preferred search order observation, I would not count on it working the same way with all systems, all Pythons, or even all directory names.

Good luck

More information about the Python-list mailing list