Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19717

changing sys.path

Date 2012-02-01 16:15 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
Subject changing sys.path
Newsgroups comp.lang.python
Message-ID <mailman.5303.1328112912.27778.python-list@python.org> (permalink)

Show all headers | View raw


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)?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

changing sys.path Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-01 16:15 +0000
  Re: changing sys.path jmfauth <wxjmfauth@gmail.com> - 2012-02-01 09:06 -0800
  Re: changing sys.path Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-01 09:17 -0800
    Re: changing sys.path Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-10 13:08 +0000
    Re: changing sys.path Dave Angel <d@davea.name> - 2012-02-10 09:24 -0500
    Re: changing sys.path Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-10 14:51 +0000
    Re: changing sys.path Dave Angel <d@davea.name> - 2012-02-10 10:06 -0500
    Re: changing sys.path Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-10 15:14 +0000
    Re: changing sys.path Peter Otten <__peter__@web.de> - 2012-02-10 16:27 +0100
    Re: changing sys.path Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-10 15:38 +0000
    Re: changing sys.path Peter Otten <__peter__@web.de> - 2012-02-10 16:40 +0100
    Re: changing sys.path Peter Otten <__peter__@web.de> - 2012-02-10 17:00 +0100
    Re: changing sys.path Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-10 20:58 +0000
  Re: changing sys.path Tim Roberts <timr@probo.com> - 2012-02-02 21:10 -0800
  Re: changing sys.path John Nagle <nagle@animats.com> - 2012-02-08 13:43 -0800

csiph-web