changing sys.path
Tim Roberts
timr at probo.com
Fri Feb 3 00:10:12 EST 2012
Andrea Crotti <andrea.crotti.0 at gmail.com> 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 at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list