def find_module(self, fullname, path=None):
if self._called:
# already handled
return
if fullname not in ('pylab', 'matplotlib.pyplot'):
# not matplotlib
return
# don't call me again
self._called = True
try:
# remove myself from the import hooks
sys.meta_path = [loader for loader in sys.meta_path if loader is not self]
except ValueError:
pass
ip = get_ipython()
if ip is None:
# not in an interactive environment
return
if ip.pylab_gui_select:
# backend already selected
return
if hasattr(ip, 'kernel'):
# default to inline in kernel environments
ip.enable_matplotlib('inline')
else:
print('enabling matplotlib')
ip.enable_matplotlib()
# install the finder immediately
评论列表
文章目录