mplimporthook.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:sci-pype 作者: jay-johnson 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号