I am trying to make a module discoverable on a system where I don't have write access to the global site-packages
directory, and without changing the environment (PYTHONPATH
). I have tried to place a .pth
file in the same directory as a script I'm executing, but it seems to be ignored. E.g., I created a file extras.pth
with the following content:
N:\PythonExtras\lib\site-packages
But the following script, placed and run in the same directory, prints False
.
import sys
print r"N:\PythonExtras\lib\site-packages" in sys.paths
The only directory in sys.path
to which I have write access is the directory containing the script. Is there another (currently non-existent) directory where I could place extras.pth
and have it be seen? Is there a better way to go about this?
I'm using python 2.7 on Windows. All .pth
questions I could find here use the system module directories.
Edit: I've tracked down the Windows per-user installation directory, at %APPDATA%\Python\Python27\site-packages
. I can place a module there and it will be imported, but if I put a .pth
file there, it has no effect. Is this really not supposed to work, or am I doing something wrong?