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


Groups > comp.lang.python > #20163

Re: changing sys.path

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'imports': 0.07; 'subject:changing': 0.07; 'extension.': 0.09; 'namespace': 0.09; 'am,': 0.12; 'declaration': 0.16; 'strangely': 0.16; 'cc:addr :python-list': 0.16; 'wrote:': 0.18; 'thanks,': 0.19; 'cc:no real name:2**0': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'path,': 0.23; 'code': 0.26; 'cc:addr:gmail.com': 0.28; 'putting': 0.28; 'example': 0.29; 'problem': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'thread': 0.32; 'list': 0.32; 'changing': 0.32; "won't": 0.33; 'header:User-Agent:1': 0.33; 'it?': 0.33; 'something': 0.35; 'cc:2**1': 0.36; 'issue': 0.37; 'but': 0.37; 'received:192': 0.38; 'think': 0.38; 'suggestions': 0.39; 'more': 0.61; 'saw': 0.66; 'was:': 0.67; 'header:Reply- To:1': 0.70; 'care': 0.71; 'reply-to:no real name:2**0': 0.72; 'andrea': 0.84; 'directories,': 0.84; '(every': 0.91
Date Fri, 10 Feb 2012 09:24:50 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111109 Thunderbird/3.1.16
MIME-Version 1.0
To Andrea Crotti <andrea.crotti.0@gmail.com>
Subject Re: changing sys.path
References <mailman.5303.1328112912.27778.python-list@python.org> <d0253e03-fed0-40db-8a7a-e9195ce92889@k28g2000yqc.googlegroups.com> <4F3516CC.1070401@gmail.com>
In-Reply-To <4F3516CC.1070401@gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:0SoaxVhZDOcyjZCm2Wm75rreDVjoARD3NoI96gG6zXi 28x6Ih1oF9E6wYl8lKT0hlcKKnTsVM6BAuJPwN6/i1vQ/RPMUN PMFWgWbLmQd9yBDL2rZgS8t0tOm+Zbnb1B3Mdk+ikOov0kBh8d zuC4lg7hZT3oYWdRafIo7NCkwJp5fixsRWSr5P4QjrFSbFlHR+ +lz397vjMa862qXxWxA1fHxcx21zwMa7OFHrS6ZqYMAJ6XKK8L ja/yNPgH8tiIJZMT79rSF8Ipm9AXPXnjAyU5YTPKgXTm6FfxdW lYOBQ1WaeGJ4BMGeUYTLibGOW4TH3NvbknZmYHLo+N9cuagft8 NZIqhWNWkVEnNuSI9qUk=
Cc python-list@python.org, Rick Johnson <rantingrickjohnson@gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5659.1328883901.27778.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328883901 news.xs4all.nl 6845 [2001:888:2000:d::a6]:45460
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20163

Show key headers only | View raw


On 02/10/2012 08:08 AM, Andrea Crotti wrote:
> I think I finally located the issue with the sys.path extension.
>
> The problem is that I have many namespace directories, for example
>
> lib:
>  - sub1
>  - sub2
>
> lib:
>   - sub3
>   - sub4
>
> But to have everything working I had lib.sub3 in easy-install.pth.
> Now if I try to add something else to the path it doesn't take care of 
> the namespace
> declaration
> (every __init__.py in the packages contains: 
> __import__('pkg_resources').declare_namespace(__name__))
> and just doesn't find the other submodules..
>
> If I try to add manually lib.sub1, lib.sub2 changing the sys.path the 
> imports will only work for the first one.
>
> Strangely if I just create a dev_main.pth in site-packages containing 
> the same paths, everything works perfectly.
>
> Any suggestions now that the problem is more clear?
> Thanks,
> Andrea

The only code I saw in this thread was:

sys.path.extend(paths_to_add)

Can you add a print of paths_to_add, and of sys.path after you execute it?

If there's only one path, are you putting it in a list anyway?  If not 
then it won't do what you expect.



-- 

DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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