python: using __import__ to import a module which in turn generates an ImportError

Posted by bbb on Stack Overflow See other posts from Stack Overflow or by bbb
Published on 2010-05-19T10:37:23Z Indexed on 2010/05/19 10:40 UTC
Read the original article Hit count: 427

Filed under:
|
|

Hi there,

I have a funny problem I'd like to ask you guys ('n gals) about.

I'm importing some module A that is importing some non-existent module B. Of course this will result in an ImportError.

This is what A.py looks like

import B

Now let's import A

>>> import A
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/importtest/A.py", line 1, in <module>
  import B
ImportError: No module named B

Alright, on to the problem. How can I know if this ImportError results from importing A or from some corrupt import inside A without looking at the error's string representation.

The difference is that either A is not there or does have incorrect import statements.

Hope you can help me out...

Cheers bb

© Stack Overflow or respective owner

Related posts about python

Related posts about import