[Q] ImportError by __import__() on Python >= 3.4

Michael Selik michael.selik at gmail.com
Mon Jun 6 18:28:00 EDT 2016


On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwata <kwa at kuwata-lab.com> wrote:

> I have a trouble around __import__().
>

The docs for __import__ strongly recommend that you use importlib instead
https://docs.python.org/3.5/library/importlib.html#importlib.import_module

The docs for ``importlib.import_module`` suggest that you use
``invalidate_caches`` if you are importing dynamically generated files.
https://docs.python.org/3.5/library/importlib.html#importlib.invalidate_caches

I think you'll find this fixes your bug.



More information about the Python-list mailing list