Circular import problem

bvdp bob at mellowood.ca
Thu Jul 12 22:36:16 EDT 2007


I'm going quite nutty here with an import problem. I've got a fairly
complicated program (about 12,000 lines in 34 modules). I just made
some "improvements" and get the following error:

bob$ mma
Traceback (most recent call last):
  File "/usr/local/bin/mma", line 55, in <module>
    import MMA.main
  File "/usr/local/share/mma/MMA/main.py", line 33, in <module>
    import MMA.docs
  File "/usr/local/share/mma/MMA/docs.py", line 34, in <module>
    import MMA.grooves
  File "/usr/local/share/mma/MMA/grooves.py", line 41, in <module>
    import MMA.auto
  File "/usr/local/share/mma/MMA/auto.py", line 35, in <module>
    import MMA.parse
  File "/usr/local/share/mma/MMA/parse.py", line 2052, in <module>
    'AUTHOR':           MMA.docs.docAuthor,
AttributeError: 'module' object has no attribute 'docs'

I can fix this by deleting a line in docs.py. Just take out the
"import MMA.grooves" and all works. What I really don't get is that in
the middle of this module which is now NOT loading "grooves.py" I have
a command to access a function in that module and it works.

Yes, grooves.py has an import docs.py. And there are lots of other
such imports in the program.

So, I have to assume that the error is being generated by some other
modules loading in the grooves.py stuff ... but  really have no idea.

Is there anything I can do to trace though this and get it working
properly?

Oh, this is python 2.5.1 on Ubuntu Linux.

Thanks.




More information about the Python-list mailing list