Understanding .pth files
ian.g.kelly at gmail.com
Sun Aug 28 18:32:23 CEST 2011
On Sat, Aug 27, 2011 at 10:42 AM, Josh English
<Joshua.R.English at gmail.com> wrote:
> According to the docs, I should be able to put a file in the site-packages directory called xmldb.pth pointing anywhere else on my drive to include the package. I'd like to use this to direct Python to include the version in the dev folder and not the site-packages folder.
The name of the .pth file is not important. Python uses it to add
locations to sys.path; it doesn't care what packages might be
contained at those locations.
> So my C:\Python27\lib\site-packages\xmldb.pth file has one line:
The final xmldb is the actual package, yes? The directory in the .pth
file should be one inside which Python can find packages, not a
package itself. So the file should have just "c:\dev\XmlDB". Then
when you do "import xmldb", Python will look inside the
"c:\dev\XmlDB", find the xmldb package, and import it.
> (I've tried the slashes the other way, too, but it doesn't seem to work).
> Is the only solution to delete the installed library and add the dev folder to my site.py file?
The preferred solution here is to use virtualenv to set up your
development environment without having to modify the installed version
in the system site-packages at all.
More information about the Python-list