Skip to content

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

Closed
@richman2024

Description

@richman2024

Bug summary

import matplotlib.pyplot as plt

Nomatter what drawing behavior(plot, scatter...) I uesd, I would always get below error:

Traceback (most recent call last):
  File "dt.py", line 14, in <module>
    plt.scatter(x, y, s=area, c=colors, alpha=0.5)
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 2817, in scatter
    __ret = gca().scatter(
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 2272, in gca
    return gcf().gca(**kwargs)
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 865, in gcf
    return figure()
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 809, in figure
    FigureClass=FigureClass, **kwargs)
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 324, in new_figure_manager
    _warn_if_gui_out_of_main_thread()
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 314, in _warn_if_gui_out_of_main_thread
    if (_get_required_interactive_framework(_get_backend_mod())
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 217, in _get_backend_mod
    switch_backend(dict.__getitem__(rcParams, "backend"))
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 262, in switch_backend
    switch_backend(candidate)
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 282, in switch_backend
    class backend_mod(matplotlib.backend_bases._Backend):
  File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 283, in backend_mod
    locals().update(vars(importlib.import_module(backend_name)))
  File "C:\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Python37\Lib\site-packages\matplotlib\backends\backend_qtagg.py", line 12, in <module>
    from .backend_qt import (
  File "C:\Python37\Lib\site-packages\matplotlib\backends\backend_qt.py", line 76, in <module>
    for mod, key in [
  File "C:\Python37\Lib\site-packages\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'

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

x = np.array([1, 2, 3, 4, 5, 6, 7, 8])
y = np.array([1, 4, 9, 16, 7, 11, 23, 18])

plt.scatter(x, y)
plt.show()

Actual outcome

Traceback (most recent call last): File "dt.py", line 14, in plt.scatter(x, y, s=area, c=colors, alpha=0.5) File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 2817, in scatter __ret = gca().scatter( File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 2272, in gca return gcf().gca(**kwargs) File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 865, in gcf return figure() File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 809, in figure FigureClass=FigureClass, **kwargs) File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 324, in new_figure_manager _warn_if_gui_out_of_main_thread() File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 314, in _warn_if_gui_out_of_main_thread if (_get_required_interactive_framework(_get_backend_mod()) File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 217, in _get_backend_mod switch_backend(dict.getitem(rcParams, "backend")) File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 262, in switch_backend switch_backend(candidate) File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 282, in switch_backend class backend_mod(matplotlib.backend_bases.Backend): File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 283, in backend_mod locals().update(vars(importlib.import_module(backend_name))) File "C:\Python37\lib\importlib_init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Python37\Lib\site-packages\matplotlib\backends\backend_qtagg.py", line 12, in from .backend_qt import ( File "C:\Python37\Lib\site-packages\matplotlib\backends\backend_qt.py", line 76, in for mod, key in [ File "C:\Python37\Lib\site-packages\matplotlib\backends\backend_qt.py", line 76, in for mod, key in [ TypeError: int() argument must be a string, a bytes-like object or a number, not 'KeyboardModifier'

Expected outcome

Scatter draw

Additional information

No response

Operating system

Windows

Matplotlib Version

3.5.3

Matplotlib Backend

Traceback (most recent call last): File "", line 1, in File "C:\Python37\Lib\site-packages\matplotlib_init_.py", line 1172, in get_backend return rcParams['backend'] File "C:\Python37\Lib\site-packages\matplotlib_init_.py", line 674, in getitem plt.switch_backend(rcsetup._auto_backend_sentinel) File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 262, in switch_backend switch_backend(candidate) File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 282, in switch_backend class backend_mod(matplotlib.backend_bases.Backend): File "C:\Python37\Lib\site-packages\matplotlib\pyplot.py", line 283, in backend_mod locals().update(vars(importlib.import_module(backend_name))) File "C:\Python37\lib\importlib_init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Python37\Lib\site-packages\matplotlib\backends\backend_qtagg.py", line 12, in from .backend_qt import ( File "C:\Python37\Lib\site-packages\matplotlib\backends\backend_qt.py", line 76, in for mod, key in [ File "C:\Python37\Lib\site-packages\matplotlib\backends\backend_qt.py", line 76, in for mod, key in [ TypeError: int() argument must be a string, a bytes-like object or a number, not 'KeyboardModifier'

Python version

3.7.0

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions