Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Qt4Agg: RuntimeError: call __init__ twice #5293

Closed
@quazgar

Description

@quazgar

With Matplotlib 1.5.0-rc2 (just installed by Debian testing), consider the following python session:

$ ipython3
Python 3.4.3+ (default, Oct 10 2015, 09:15:38)
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import matplotlib

In [2]: matplotlib.__version__
Out[2]: '1.5.0rc2'

In [3]: matplotlib.use("Qt4Agg")

In [4]: matplotlib.rcParams["backend.qt4"] = "PySide"

In [5]: from matplotlib.backends.backend_qt4agg import FigureCanvas

In [6]: from matplotlib.figure import Figure

In [7]: fig = Figure()

In [8]: canvas = FigureCanvas(fig)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-8-9faf89066fc2> in <module>()
----> 1 canvas = FigureCanvas(fig)

/usr/lib/python3/dist-packages/matplotlib/backends/backend_qt4agg.py in __init__(self, figure)
     70             print('FigureCanvasQtAgg: ', figure)
     71         FigureCanvasQT.__init__(self, figure)
---> 72         FigureCanvasQTAggBase.__init__(self, figure)
     73         FigureCanvasAgg.__init__(self, figure)
     74         self._drawRect = None

/usr/lib/python3/dist-packages/matplotlib/backends/backend_qt5agg.py in __init__(self, figure)
     63
     64     def __init__(self, figure):
---> 65         super(FigureCanvasQTAggBase, self).__init__(figure=figure)
     66         self._agg_draw_pending = False
     67

/usr/lib/python3/dist-packages/matplotlib/backends/backend_qt4.py in __init__(self, figure)
     69
     70         # Note different super-calling style to backend_qt5
---> 71         QtWidgets.QWidget.__init__(self)
     72         FigureCanvasBase.__init__(self, figure)
     73         self.figure = figure

RuntimeError: You can't initialize an object twice!

In [9]:

This code used to work fine with matplotlib 1.4.3 and now breaks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions