Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: qt_compat error in handling pyside6 Qt enumerations for pyplot #30041

Closed
Labels
@btishmack

Description

@btishmack

Bug summary

pyplot cannot be imported. Raises an error pertaining to converting Qt Enumerations to integers.

Code for reproduction

importmatplotlib.pyplotasplt"""Error is thrown on import"""# addendumimportmatplotlib# This also produces the same error (same source)matplotlib.get_backend()

Actual outcome

Traceback (most recent call last):
File ".../test.py", line 2, in
import matplotlib.pyplot as plt
File "/.local/lib/python3.10/site-packages/matplotlib/pyplot.py", line 2230, in
switch_backend(rcParams["backend"])
File "
/.local/lib/python3.10/site-packages/matplotlib/init.py", line 672, ingetitem
plt.switch_backend(rcsetup._auto_backend_sentinel)
File "/.local/lib/python3.10/site-packages/matplotlib/pyplot.py", line 247, in switch_backend
switch_backend(candidate)
File "
/.local/lib/python3.10/site-packages/matplotlib/pyplot.py", line 267, in switch_backend
class backend_mod(matplotlib.backend_bases._Backend):
File "/.local/lib/python3.10/site-packages/matplotlib/pyplot.py", line 268, in backend_mod
locals().update(vars(importlib.import_module(backend_name)))
File "/usr/lib64/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
/.local/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py", line 12, in
from .backend_qt import (
File "/.local/lib/python3.10/site-packages/matplotlib/backends/backend_qt.py", line 73, in
_MODIFIER_KEYS = [
File "
/.local/lib/python3.10/site-packages/matplotlib/backends/backend_qt.py", line 74, in
(_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

Nothing, execute and exit

Additional information

The source of the error is the enumerations used in PySide6 (for me). Inmatplotlib/qt_compat.py, the
enumerations returned from _enum cannot be directly converted to integers with _to_int; the issue can be resolved by extending the QT_API condition in _to_int()[qt_compat.py+143] to include "pyside6".

Alternatively, I can set QT_API in the environment from the various expected values at the top of qt_compat.py (pyside6, pyqt5, pyside2, etc.); pyside6 is the only compatibility mode which raises this particular error.

Operating system

Fedora

Matplotlib Version

3.5.1

Matplotlib Backend

PySide6 (matplotlib.get_backend() also raises the same error described)

Python version

3.10.11

Jupyter version

n-a

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp