changing sys.path

Andrea Crotti andrea.crotti.0 at gmail.com
Wed Feb 1 17:15:05 CET 2012


So suppose I want to modify the sys.path on the fly before running some code
which imports from one of the modules added.

at run time I do
sys.path.extend(paths_to_add)

but it still doesn't work and I get an import error.

If I take these paths and add them to site-packages/my_paths.pth
everything works, but at run-time the paths which I actually see before
importing are exactly the same.

So there is something I guess that depends on the order, but what can I
reset/reload to make these paths available (I thought I didn't need 
anything in theory)?



More information about the Python-list mailing list