''Cursors' object has no attribute 'RESIZE_HORIZONTAL' in qt bindings with %matplotlib qt

That is what appears when I run %matplotlib qt.

Along with this error message, I tried widget which gave me the same answer (+ try to use qt). PyQt5 is imported, as well as other packages. Otherwise, when I use %matplotlib inline, I don't have a new window, only the regular graph. Would you be so kind as to answer my question, for best visualisations.

AttributeError                            Traceback (most recent call last)
/var/folders/13/d095gb7d3w707hsyf79x8q4r0000gn/T/ipykernel_18255/4121196805.py in <module>
----> 1 get_ipython().run_line_magic('matplotlib', 'qt')

~/miniconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2362                 kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2363             with self.builtin_trap:
-> 2364                 result = fn(*args, **kwargs)
   2365             return result
   2366 

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

~/miniconda3/lib/python3.9/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~/miniconda3/lib/python3.9/site-packages/IPython/core/magics/pylab.py in matplotlib(self, line)
     97             print("Available matplotlib backends: %s" % backends_list)
     98         else:
---> 99             gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
    100             self._show_matplotlib_backend(args.gui, backend)
    101 

~/miniconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
   3544                 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
   3545 
-> 3546         pt.activate_matplotlib(backend)
   3547         configure_inline_support(self, backend)
   3548 

~/miniconda3/lib/python3.9/site-packages/IPython/core/pylabtools.py in activate_matplotlib(backend)
    357     from matplotlib import pyplot as plt
    358 
--> 359     plt.switch_backend(backend)
    360 
    361     plt.show._needmain = False

~/miniconda3/lib/python3.9/site-packages/matplotlib/pyplot.py in switch_backend(newbackend)
    219         # `plt.ion()` so register it again here.  This is safe because multiple
    220         # calls to `install_repl_displayhook` are no-ops and the registered
--> 221         # function respects `mpl.is_interactive()` to determine if it should
    222         # trigger a draw.
    223         install_repl_displayhook()

~/miniconda3/lib/python3.9/importlib/__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

~/miniconda3/lib/python3.9/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/miniconda3/lib/python3.9/importlib/_bootstrap.py in _find_and_load(name, import_)

~/miniconda3/lib/python3.9/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

~/miniconda3/lib/python3.9/importlib/_bootstrap.py in _load_unlocked(spec)

~/miniconda3/lib/python3.9/importlib/_bootstrap_external.py in exec_module(self, module)

~/miniconda3/lib/python3.9/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~/miniconda3/lib/python3.9/site-packages/matplotlib/backends/backend_qt5agg.py in <module>
      5 
      6 backends._QT_FORCE_QT5_BINDING = True
----> 7 from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
      8     _BackendQTAgg, FigureCanvasQTAgg, FigureManagerQT, NavigationToolbar2QT,
      9     backend_version,  FigureCanvasAgg,  FigureCanvasQT

~/miniconda3/lib/python3.9/site-packages/matplotlib/backends/backend_qtagg.py in <module>
     10 from .. import cbook
     11 from .backend_agg import FigureCanvasAgg
---> 12 from .backend_qt import (
     13     QtCore, QtGui, QtWidgets, _BackendQT, FigureCanvasQT, FigureManagerQT,
     14     NavigationToolbar2QT, backend_version)

~/miniconda3/lib/python3.9/site-packages/matplotlib/backends/backend_qt.py in <module>
     88         (cursors.SELECT_REGION, "CrossCursor"),
     89         (cursors.WAIT, "WaitCursor"),
---> 90         (cursors.RESIZE_HORIZONTAL, "SizeHorCursor"),
     91         (cursors.RESIZE_VERTICAL, "SizeVerCursor"),
     92     ]

AttributeError: 'Cursors' object has no attribute 'RESIZE_HORIZONTAL'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source