Skip to content
  • PHP-Proxy

    PHP-Proxy

    Error accessing resource: 429 - Too Many Requests

  • Notifications You must be signed in to change notification settings
  • Fork 8k

[Bug]: import matplotlib.backends.backend_qt5agg error for pyside6 #24212

@koutoftimer

Description

@koutoftimer

Bug summary

_to_int = operator.attrgetter("value") if QT_API == "PyQt6" else int

Have to check for "PySide6" too.

Code for reproduction

$ QT_API=pyside6 python -c "import matplotlib.backends.backend_qt5agg"

Actual outcome

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/tmp.atoQSuHf68/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5agg.py", line 7, in <module>
    from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
  File "/tmp/tmp.atoQSuHf68/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py", line 12, in <module>
    from .backend_qt import QtCore, QtGui, _BackendQT, FigureCanvasQT
  File "/tmp/tmp.atoQSuHf68/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt.py", line 72, in <module>
    _MODIFIER_KEYS = [
  File "/tmp/tmp.atoQSuHf68/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt.py", line 73, in <listcomp>
    (_to_int(getattr(_enum("QtCore.Qt.KeyboardModifier"), mod)),
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'KeyboardModifier'

Expected outcome

no errors

Additional information

PySide6==6.4.0

Operating system

GNU\Gentoo Linux

Matplotlib Version

3.6.1

Matplotlib Backend

same exception

Python version

3.10.6

Jupyter version

not installed

Installation

pip

Activity

koutoftimer

koutoftimer commented on Oct 18, 2022

@koutoftimer
Author

I suppose it is already fixed in the main branch.

def _setup_pyqt5plus():
global QtCore, QtGui, QtWidgets, __version__
global _getSaveFileName, _isdeleted, _to_int
if QT_API == QT_API_PYQT6:
from PyQt6 import QtCore, QtGui, QtWidgets, sip
__version__ = QtCore.PYQT_VERSION_STR
QtCore.Signal = QtCore.pyqtSignal
QtCore.Slot = QtCore.pyqtSlot
QtCore.Property = QtCore.pyqtProperty
_isdeleted = sip.isdeleted
_to_int = operator.attrgetter('value')
elif QT_API == QT_API_PYSIDE6:
from PySide6 import QtCore, QtGui, QtWidgets, __version__
import shiboken6
def _isdeleted(obj): return not shiboken6.isValid(obj)
if parse_version(__version__) >= parse_version('6.4'):
_to_int = operator.attrgetter('value')
else:
_to_int = int
elif QT_API == QT_API_PYQT5:
from PyQt5 import QtCore, QtGui, QtWidgets
import sip
__version__ = QtCore.PYQT_VERSION_STR
QtCore.Signal = QtCore.pyqtSignal
QtCore.Slot = QtCore.pyqtSlot
QtCore.Property = QtCore.pyqtProperty
_isdeleted = sip.isdeleted
_to_int = int
elif QT_API == QT_API_PYSIDE2:
from PySide2 import QtCore, QtGui, QtWidgets, __version__
try:
from PySide2 import shiboken2
except ImportError:
import shiboken2
def _isdeleted(obj):
return not shiboken2.isValid(obj)
_to_int = int
else:
raise AssertionError(f"Unexpected QT_API: {QT_API}")
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
if QT_API in [QT_API_PYQT6, QT_API_PYQT5, QT_API_PYSIDE6, QT_API_PYSIDE2]:
_setup_pyqt5plus()

koutoftimer

koutoftimer commented on Oct 18, 2022

@koutoftimer
Author

Yes it is fixed already. Can't reproduce the issue with main branch.

$ pip freeze
matplotlib @ git+https://github.com/matplotlib/matplotlib.git@80b15fb17be6455680a4830d0644731f8ee6bb8b
PySide6==6.4.0

For me works fine.

oscargus

oscargus commented on Oct 18, 2022

@oscargus
Member

Was fixed in #24158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [Bug]: import matplotlib.backends.backend_qt5agg error for pyside6 · Issue #24212 · matplotlib/matplotlib