[issue13912] ImportError using __import__ and relative level 1

Brett Cannon report at bugs.python.org
Mon Jan 30 23:42:25 CET 2012


Brett Cannon <brett at python.org> added the comment:

I see your mistake now: you need to call it as __import__('pkgB', globals(), index=1), else __import__ has no clue how to anchor your import in the relative package space.

Try that and let me know if it makes it work.

And why exactly are you trying to call __import__ directly? You should be using importlib.import_module() for programmatic imports.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13912>
_______________________________________


More information about the Python-bugs-list mailing list