How to add a Python import path using a .pth file

If you put a .pth file in the site-packages directory containing a path, python searches this path for imports. So I have a sth.pth file there that simply contains:

K:\Source\Python\lib

In that directory there are some normal Python modules:

logger.py
fstools.py
...

This allows to directly import these modules from other scripts:

import logger

log = logger.Log()
...

Leave a Comment