Reputation: 932
I'm confused by the behaviour of importlib
in the interactive IPython shell. When I run:
import importlib.reload as ilrel
I get the error ImportError: No module named 'importlib.reload'
. This is exactly how I import other modules, such as matplotlib.pyplot
.
Currently I've been simply importing importlib
alone, then using importlib.reload(<module name>)
. This isn't a major issue but why does the first method not work?
Upvotes: 2
Views: 2980
Reputation: 599530
Because reload
is not a module, it's a function within the importlib
module. There is nothing specific about importlib; this is how imports work for all modules.
If you just want the function itself, you can do from importlib import reload
.
Note also that this function is only available in Python 3.4+.
Upvotes: 6