This was strange, I had a bunch of classes in a file and was trying to import one of them from a file in a child folder.
The package looked like this:
/main_classes.py <– “import child” was in here way on top
/child/__init__.py <– For every file in this folder, import it
/child/some_file.py <– Import a class in main_classes.py *Error*
The reason was that I was doing “import child” way on top before implementing the class I was importing in some_file.py.
I moved the “import child” line from the top of the main_class.py to the constructor of the class I was implementing and it fixed the issue.
I hope this made sense
(and I know it will to the person with this problem
)

I'm a programmer at 
Thanks a lot! That was a very useful post
And yes, it made sense
Comment
yes, kewl post, mr. snake-charmer — solved my problem too
now i can continue choking the snake.
Comment
and what happen if you hace a bouch of classes on:
/ab/ab_classes.py
and now make a package like this:
/a/a_classes.py
/b/b_classes.py
???
Comment
ok ok ok I got, niceeeee. thanks.
Comment
Thx for the info – it also solved my problem – but i had to reread your post quite often to understand it.
The problem is a **circular Reference** – as child gets imported in parent, which also wants to import parts of parent.
Comment
thanks a lot for the post. it does make sense to me.
Comment
Thanks a lot, saved me a lot of searching
Comment
thanks so much for solving my problem.
***would take “years” to find it.heheheeh…
saved me a lot of searching [2]!
Comment
You are putting the imports in your constructor? That seems a little weird (and extremely against the standards lol). Alternatively you could separate the parent code, and re-order the imports.
For instance:
/parent1.py/ <–first import parent2, then children
/parent2.py/ <– part of parent code needed by children
/children/childa.py
/children/childb.py <– imports parent2
/children/__init__.py <– same as before
Comment
Thank you, thank you, thank you, thank you!
Comment
I had this same issue using mod_python trying to import psycopg2. I had to move the
import psycopg2
under
def handler(req):
import psycopg2
…
Comment
Can’t believe this was the error i was having. One million thanks to you pal!!!
Comment