allow scripts to use .pth files?

John Machin sjmachin at
Sun Jul 8 22:53:42 CEST 2007

On Jul 8, 10:53 pm, samwyse <samw... at> wrote:
> On Jul 3, 9:35 am, Alan Isaac <ais... at> wrote:
> > Suppose I have a directory `scripts`.
> > I'd like the scripts to have access to a package
> > that is not "installed", i.e., it is not on sys.path.
> > On this list, various people have described a variety
> > of tricks they use, but nobody has proposed a
> > pretty way to allow this.
> > I am therefore assuming there is not one. (?)
> > How about allowing a `scripts.pth` file in such a `scripts`
> > directory, to work like a path configuration file?
> > (But to be used only when __name__=="__main__".)
> > Drawbacks?
> > Alan Isaac
> before i can adequately shoot down your proposal, i need more
> information.
> first, how does the interpreter know to look in 'scripts' for your
> 'scripts.pyh' file and not in '.' or '~' or sys.argv[0] or someplace
> else?

I got the impression that the OP was suggesting that the interpreter
look in the directory in which it found the script.

> and you do know, don't you, that if you run 'scripts/
>' then 'scripts' is automagically prepended to the search
> path for modules?

I got the impression that the problem was that the package was not
only not on sys.path but also not in the same directory as the script
that wanted to import it. Otherwise the OP's script.p?h file need only
contain ".\n" (or the path to the  directory in which it resided!!),
and I doubt that he was proposing something so silly.

I'm curious whether you think that the OP's use of ".pth" was a typo,
and whether you have read this:


More information about the Python-list mailing list