Re: changing sys.path



Andrea Crotti <andrea.crotti.0@xxxxxxxxx> wrote:

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.

Are you actually adding multiple paths? One possible cause for error would
be this:
sys.path.extend( '/usr/local/lib' )

That succeeds, but it doesn't do what you meant. It adds "/" as a path,
then "u", then "s", then "r", and so on.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.