% matplotlib inline: object 'NoneType' does not have attribute 'is_interactive'

I do not know why this happened. How can I solve it?

In [1]: %matplotlib inline

And I got this:

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 overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **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'
+4
source share
1 answer

For me

pip install jupyter_console

then

ipython console (jupyter console recommended)

In [1]:% matplotlib inline

works fine.

ipython console --matplotlib inline

will cause an error:

Unrecognized flag: '--matplotlib'

0
source

Source: https://habr.com/ru/post/1659305/


All Articles