New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FigureCanvasQT backend_qt5agg bug (backend_qt4agg) works #3656
Comments
This sounds similar to #3623. It turned out that this was because I had the env variable QT_API set to pyqt which resulted in pyqt4 being imported into the qt5 backend. This is fixed in 1.4.1rc1 That being said the line still looks wrong to me. You are right that super will first call init on the first inherited class and if not found move on according to the method resolution order: http://stackoverflow.com/questions/1848474/method-resolution-order-mro-in-new-style-python-classes But any combination of explicitly calling init on the two parent classes that I have tried fails. |
Could you be more specific ? What should I do |
The easies is to check if the environmental variable is set. import os
print os.environ.get('QT_API') If this prints either pyqt or pyside it is likely this issue that you are seeing. Otherwise something else is wrong. Without knowing how you have installed python and matplotlib it is hard to tell you how to install matplotlib but usually nothing is easy or simple on windows... If you have installed all the packages from scratch you might be able to use the one from here http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib |
QT_API isn't set. When I import FigureCanvasQTAgg from backend_qt4agg it is working well even if I have only QT5 installed and not QT4. |
Thanks for testing this confirms that there is some deeper problem somewere. I will try to have a closer look of what is happening but it might take some time |
I workaround using qt4agg. Hope I was helpfull. |
Hello, |
No problem, Just wanted to keep you up to date. |
As far as I can tell, this issue still exists:
|
@jrversteegh Do you have pyqt5 installed? |
Only just after I ran this test ;), so automatic fallback to pyqt4 is the issue here. I guess it shouldn't do that when I explicitly specify the Qt5Agg backend. It should just complain that PyQt5 or PySide2 isn't installed. |
The issue that brought me here remains: an error in the same place with PySide2.
but I guess that's a PyQt5 <-> PySide2 compatibility issue. |
Does pyside2 not do cooperative inheritance? If so, it just needs to keep going through the qt4 shims. @jrversteegh That should get it's own issue. |
@tacaswell PySide2 and PySide6 both do not yet properly support cooperative multiple inheritance:
There are many different bugs stemming from this documented in the Qt for Python Development Notes 2021 Secondly, Therefore, To work around this, # To work around lack of cooperative inheritance in PySide2 and
# PySide6, when calling FigureCanvasQT.__init__, we temporarily patch
# QWidget.__init__ by a cooperative version, that first calls
# QWidget.__init__ with no additional arguments, and then finds the
# next class in the MRO with an __init__ that does support cooperative
# inheritance (i.e., not defined by the PyQt4 or sip, or PySide{,2,6}
# or Shiboken packages), and manually call its `__init__`, once again
# passing the additional arguments. This method was recommended by Raymond Hettinger in his PyCon 2015 talk Super considered super! and his corresponding blog post UpdateNote that this is a PySide problem, but in It is important to recognize that the tool ASIDE: I have no articles or quotes to back this up, but I imagine "sip" is a cute (haha, get it, "cute"; However, for
Shiboken (pronounced Shi bō ken, 死某剣), if translated from the kanjis, means "death certain sword" or "death sword". I can't help but think the name was a "poke" (get it, poke) at "sip", though it is claimed to mean nothing. |
In this example,
http://matplotlib.org/examples/user_interfaces/embedding_in_qt4.html (embedding_in_qt4.py)
When replacing
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
through
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
I got this error
File "C:\Python34\lib\site-packages\matplotlib\backends\backend_qt5.py", line 238, in init
super(FigureCanvasQT, self).init(figure=figure)
When looking at class FigureCanvasQT in backend_qt5.py and backend_qt4.py it seems that super is calling init on first inherited class (QtWidgets.QWidget) instead of second one (FigureCanvasBase).
Let me know if I was not clear enough and if it is realy a bug or a missusage.
The text was updated successfully, but these errors were encountered: