import problems.

A

Antoon Pardon

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top