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


Groups > comp.lang.python > #18827

Re: import problems.

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.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.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'importerror:': 0.07; 'python': 0.08; '__name__': 0.09; 'problem:': 0.09; 'am,': 0.12; 'ats': 0.16; 'subject:import': 0.16; 'cc:addr:python-list': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; '(most': 0.21; 'header:In-Reply- To:1': 0.22; 'somewhere': 0.23; 'figure': 0.23; 'debian': 0.23; 'cc:2**0': 0.24; 'traceback': 0.24; 'import': 0.27; 'problem': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'second': 0.29; 'imported': 0.30; "can't": 0.32; 'header:User-Agent:1': 0.33; 'calling': 0.34; 'last):': 0.34; 'skip:" 50': 0.34; 'file': 0.36; 'but': 0.37; 'received:192': 0.37; 'using': 0.38; 'skip:- 50': 0.39; 'why': 0.39; 'received:192.168': 0.40; 'join': 0.61; 'your': 0.61; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'pardon': 0.84
Date Wed, 11 Jan 2012 08:44:19 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15
MIME-Version 1.0
To Antoon Pardon <antoon.pardon@rece.vub.ac.be>
Subject Re: import problems.
References <4F0D8CF5.1090508@rece.vub.ac.be>
In-Reply-To <4F0D8CF5.1090508@rece.vub.ac.be>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:BirWjNjDu2iA2p+nncfwaJO38HVFeMQFk59pylP3UAw HGsjUWls3skddUwg0bTP4WQfiLd6CjAn5qZcNG0DzBOtM/D9Sw CB5QN2s42Hzqd1zJyJ58RTrov883GC0TWGDrpJGexoG5ACidtA rKzpxI/d03HnR67ic/sba/HBA0mUwsEnloPYm7Rgf1f/I33voQ o5d/h1UkJB1iTI7QiqaEi7/AnTbZkXgSfmcBqjaKFfnBVmLJ21 EMagYXZok/DIANBwWBwAdUj42CMwMDlA7H2mOe4G4JRUmrmXCu 2JTYrhiWA9JODkMtzyfS25H3QhdNqI5qCTZkGrfXq0l+Y65MPE 8STkmO8et6WgycDWCilk=
Cc python-list@python.org
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.4645.1326289470.27778.python-list@python.org> (permalink)
Lines 60
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1326289470 news.xs4all.nl 6979 [2001:888:2000:d::a6]:51742
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18827

Show key headers only | View raw


On 01/11/2012 08:21 AM, Antoon Pardon wrote:
> I have an import problem I can't figure out.
> I am using python 2.6.6 on a debian box
>
> In one directory (pylib) I have a file misc.py and
> the file testutil.py.
>
> -------------------- testutil.py ----------------------
>
> print "in", __name__
>
> from misc import Rec
>
> --------------------------------------------------------
>
> calling this file in that directory gives me this:
>
> $ python testutil.py
> in __main__
>
> In a neighbour directory I have the file ats
>
> ------------------------ atst ----------------------------
>
> import sys
>
> from os.path import join as pj, abspath
>
> print abspath("../pylib")
>
> sys.path.append(abspath("../pylib"))
>
> import testutil
>
> -----------------------------------------------------------
>
> Now calling this file in its directory gives me the following problem:
> $ python atst
> /local/home/apardon/src/projecten/pylib
> in testutil
> Traceback (most recent call last):
>   File "atst", line 9, in <module>
>     import testutil
>   File "/local/home/apardon/src/projecten/pylib/testutil.py", line 4, 
> in <module>
>     from misc import Rec
> ImportError: cannot import name Rec
>
> Why can I import Rec from misc in testutil when I call testutil.py 
> directly but not when testutil was imported itself?
In your first case, Rec.py was in the current directory, which is one of 
the specs in classpath.  In the second case, your current directory was 
somewhere else.



-- 

DaveA

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


Thread

Re: import problems. Dave Angel <d@davea.name> - 2012-01-11 08:44 -0500

csiph-web