Can I put .pth file in my work directory

2.9k Views Asked by At

G:\code\Python\hello\helloworld.py

G:\code\Python\hello\mymodule\gettime.py

G:\code\Python\hello\mypath.pth

I write gettime.py in mymodule, I'd import gettime in helloworld. I write "G:\\code\\Python\\hello\\mymodule" in mypath.pth. Can I put mypath.pth in the directory "G:\code\Python\hello"?

1

There are 1 best solutions below

5
On BEST ANSWER

No, it won't work, per the site documentation:

A path configuration file is a file whose name has the form name.pth and exists in one of the four directories mentioned above.

The four directories mentioned "above" are specific to the Python install, they're not related to the working directory. It's actually more than four (they're not including the optional user site-packages directory for instance), but the list is not arbitrarily long, and the working directory is never involved in determining what .pth files to use.