加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – %matplotlib内联:’NoneType’对象没有属性’is_int

发布时间:2020-12-20 13:14:48 所属栏目:Python 来源:网络整理
导读:我不知道为什么会这样.我该如何解决? In [1]: %matplotlib inline 我得到了这个: AttributeError: 'NoneType' object has no attribute 'is_interactive'In [1]: %matplotlib inline--------------------------------------------------------------------
我不知道为什么会这样.我该如何解决?

In [1]: %matplotlib inline

我得到了这个:

AttributeError: 'NoneType' object has no attribute 'is_interactive'


In [1]: %matplotlib inline
---------------------------------------------------------------------------
UnknownBackend                            Traceback (most recent call last)
<ipython-input-1-2b1da000a957> in <module>()
----> 1 get_ipython().magic(u'matplotlib inline')

/Users/wonderful/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self,arg_s)
   2156         magic_name,_,magic_arg_s = arg_s.partition(' ')
   2157         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158         return self.run_line_magic(magic_name,magic_arg_s)
   2159 
   2160     #-------------------------------------------------------------------------

/Users/wonderful/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self,magic_name,line)
   2077                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2078             with self.builtin_trap:
-> 2079                 result = fn(*args,**kwargs)
   2080             return result
   2081 

<decorator-gen-104> in matplotlib(self,line)

/Users/wonderful/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f,*a,**k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f,**k: f(*a,**k)
    189 
    190         if callable(arg):

/Users/wonderful/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self,line)
     98             print("Available matplotlib backends: %s" % backends_list)
     99         else:
--> 100             gui,backend = self.shell.enable_matplotlib(args.gui)
    101             self._show_matplotlib_backend(args.gui,backend)
    102 

/Users/wonderful/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self,gui)
   2945                 gui,backend = pt.find_gui_and_backend(self.pylab_gui_select)
   2946 
-> 2947         pt.activate_matplotlib(backend)
   2948         pt.configure_inline_support(self,backend)
   2949 

/Users/wonderful/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in activate_matplotlib(backend)
    292     matplotlib.rcParams['backend'] = backend
    293 
--> 294     import matplotlib.pyplot
    295     matplotlib.pyplot.switch_backend(backend)
    296 

/Users/wonderful/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
   2510 # are no-ops and the registered function respect `mpl.is_interactive()`
   2511 # to determine if they should trigger a draw.
-> 2512 install_repl_displayhook()
   2513 
   2514 ################# REMAINING CONTENT GENERATED BY boilerplate.py ##############

/Users/wonderful/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py in install_repl_displayhook()
    163             ipython_gui_name = backend2gui.get(get_backend())
    164             if ipython_gui_name:
--> 165                 ip.enable_gui(ipython_gui_name)
    166         else:
    167             _INSTALL_FIG_OBSERVER = True

/Users/wonderful/anaconda/lib/python2.7/site-packages/IPython/terminal/interactiveshell.pyc in enable_gui(self,gui)
    450     def enable_gui(self,gui=None):
    451         if gui:
--> 452             self._inputhook = get_inputhook_func(gui)
    453         else:
    454             self._inputhook = None

/Users/wonderful/anaconda/lib/python2.7/site-packages/IPython/terminal/pt_inputhooks/__init__.pyc in get_inputhook_func(gui)
     36 
     37     if gui not in backends:
---> 38         raise UnknownBackend(gui)
     39 
     40     if gui in aliases:

UnknownBackend: No event loop integration for 'inline'. Supported event loops are: qt,qt4,qt5,gtk,gtk2,gtk3,tk,wx,pyglet,glut,osx
Error in callback <function post_execute at 0x10ad69500> (for post_execute):
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/Users/wonderful/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py in post_execute()
    145 
    146             def post_execute():
--> 147                 if matplotlib.is_interactive():
    148                     draw_all()
    149 

AttributeError: 'NoneType' object has no attribute 'is_interactive'

解决方法

为了我,

pip install jupyter_console

然后

ipython console(‘jupyter console’ recommend)

In [1]: %matplotlib inline

工作得很好.

ipython console –matplotlib inline

会引发错误:

Unrecognized flag: ‘–matplotlib’

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读