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


Groups > comp.lang.python > #18832 > unrolled thread

Re: import problems.

Started byAntoon Pardon <antoon.pardon@rece.vub.ac.be>
First post2012-01-11 16:14 +0100
Last post2012-01-11 16:14 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: import problems. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2012-01-11 16:14 +0100

#18832 — Re: import problems.

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2012-01-11 16:14 +0100
SubjectRe: import problems.
Message-ID<mailman.4649.1326294899.27778.python-list@python.org>
On 01/11/2012 03:45 PM, Antoon Pardon wrote:
> On 01/11/2012 02:57 PM, Peter Otten wrote:
>> 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.
>>>       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?
>> Without looking into the details, could it be that you have two misc.py
>> files one with and one without Rec
> Well that depends on what you mean with "have".  This is what
> turned up when I searched for "misc.py"
>
> $ find /usr/local/lib /usr/lib /local/home/apardon -name misc.py 
> -print 2> /dev/null
> /usr/lib/python2.6/compiler/misc.py
> /usr/lib/pymodules/python2.6/PyQt4/uic/Compiler/misc.py
> /usr/lib/pymodules/python2.6/numpy/oldnumeric/misc.py
> /usr/lib/pymodules/python2.6/docutils/transforms/misc.py
> /usr/lib/pymodules/python2.6/docutils/parsers/rst/directives/misc.py
> /local/home/apardon/src/projecten/pylib/misc.py
>
> That last one is my file, the rest doesn't seem to be in sys.path so 
> they shouldn't interfere
> as far as I understand. Changing the name of my file to miscutil.py 
> resolves the problem though.
>
> I'll see if I can figure out more.

It seems there is a directory /usr/lib/pymodules/python2.6/misc in which 
is an empty __init.py__ file.
As far as I understand this makes misc a package on sys.path causing the 
problem.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web