One way is to add paths to your code using sys.path.
import sys sys.path.append(somepath)
Another way is to use a site that processes .pth files in addition to adding to sys.path.
import site site.addsitedir(sitedir, known_paths=None)
https://docs.python.org/library/site.html
But you probably don't want to add this to all of your linked code.
I saw a mention of the sitecustomize.py file used to do something similar, but after some testing, I couldnβt get it to work as you would expect.
It is mentioned here that sitecustomize.py auto-import ended in 2.5, if your not on 2.5 try. (just add one of the methods to add the path to the file and place it in the directory in which your program is launched) The method of operation is described in the message for users of size 2.5 and above.
http://code.activestate.com/recipes/552729/
monkut Oct 30 '08 at 5:22 2008-10-30 05:22
source share