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

Skip to content

[Bug]: TypeError: int() argument must be a string, a bytes-like object or a number, not 'KeyboardModifier' #24155

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

Closed
srikanthravipati opened this issue Oct 13, 2022 · 6 comments · Fixed by #24158
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! GUI: Qt
Milestone

Comments

@srikanthravipati
Copy link

Bug summary

Error while importing matplotlib qt backend.

The version details are as below
matplotlib: 3.6.1
pyside: 6.4.0
python: 3.9.9

on a macOS-M1 machine.

Code for reproduction

from matplotlib.backends.backend_qtagg import NavigationToolbar2QT as NavigationToolbar

Actual outcome

Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/backends/backend_qtagg.py", line 12, in
from .backend_qt import QtCore, QtGui, _BackendQT, FigureCanvasQT
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/backends/backend_qt.py", line 72, in
_MODIFIER_KEYS = [
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/backends/backend_qt.py", line 73, in
(_to_int(getattr(_enum("QtCore.Qt.KeyboardModifier"), mod)),
TypeError: int() argument must be a string, a bytes-like object or a number, not 'KeyboardModifier'

Expected outcome

No error!

Additional information

No response

Operating system

OS/X

Matplotlib Version

3.6.1

Matplotlib Backend

MacOSX

Python version

3.9.9

Jupyter version

No response

Installation

pip

@tacaswell
Copy link
Member

pyside 6.4.0 went up on pypi about 2 hours ago. I suspect something changed about how the handle enums and we will need to adjust.

This is a good first issue because the behavior is "should import" and the changes should be localized to only backend_qt.py and qt_compat.py, but medium difficulty because it will require understanding what the changes to PySide6 were and how to adapt our shim layers to work with both these changes, the previous behavior of Pyside and PyQt's behavior.

@tacaswell tacaswell added this to the v3.6.2 milestone Oct 13, 2022
@tacaswell tacaswell added GUI: Qt Good first issue Open a pull request against these issues if there are no active ones! Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues labels Oct 13, 2022
@larsoner
Copy link
Contributor

FYI I expect this to break stuff for a lot of folks. It broke a bunch of our CIs in MNE-Python :(

https://dev.azure.com/mne-tools/mne-python/_build/results?buildId=22361&view=logs&jobId=dded70eb-633c-5c42-e995-a7f8d1f99d91&j=dded70eb-633c-5c42-e995-a7f8d1f99d91&t=1ccededa-7e7e-5a92-87ce-e531d760d025

@abey79
Copy link

abey79 commented Oct 14, 2022

This is most likely related to the Enum change, see here.

@Marroh
Copy link

Marroh commented Aug 10, 2023

I resolved the issue by downgrading PySide6 to a version earlier than 6.4.0.👌

@ReubenVandezande
Copy link

Can confirm I also see this:

>>> import PySide6
>>> PySide6.__version__
'6.5.3'
>>> import matplotlib
>>> matplotlib.__version__
'3.5.3'
>>> from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../matplotlib/backends/backend_qt5agg.py", line 7, in <module>
    from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
  File ".../matplotlib/backends/backend_qtagg.py", line 12, in <module>
    from .backend_qt import (
  File ".../matplotlib/backends/backend_qt.py", line 76, in <module>
    for mod, key in [
  File ".../matplotlib/backends/backend_qt.py", line 76, in <listcomp>
    for mod, key in [
TypeError: int() argument must be a string, a bytes-like object or a number, not 'KeyboardModifier'

@rcomer
Copy link
Member

rcomer commented Apr 29, 2024

@ReubenVandezande please upgrade your Matplotlib to version 3.6.2 or higher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! GUI: Qt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants