import problems.

Antoon Pardon antoon.pardon at
Wed Jan 11 08:21:57 EST 2012

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 and
the file

-------------------- ----------------------

print "in", __name__

from misc import Rec


calling this file in that directory gives me this:

$ python
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")


import testutil


Now calling this file in its directory gives me the following problem:
$ python atst
in testutil
Traceback (most recent call last):
   File "atst", line 9, in <module>
     import testutil
   File "/local/home/apardon/src/projecten/pylib/", 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 
directly but not when testutil was imported itself?

More information about the Python-list mailing list