调用plt函数报错not ‘KeyboardModifier’

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

这个错误是由于在使用Matplotlib库时,尝试加载Qt相关的后端时发生了问题。根据错误信息,问题出现在导入backend_qt模块时。

这个错误通常是由于Matplotlib版本与其他相关库的兼容性问题导致的。可能的原因是Matplotlib版本与Qt库或其他依赖库版本不兼容。

确实只在这个库里安装了PySide6(6.4.2)和matplotlib(3.5.3)

解决方案:

代码开头增加下面2句:

c 复制代码
import matplotlib
matplotlib.use('TkAgg')
相关推荐
dev派4 小时前
AI Agent 系统中的常用 Workflow 模式(2) Evaluator-Optimizer模式
python·langchain
前端付豪6 小时前
AI 数学辅导老师项目构想和初始化
前端·后端·python
用户0332126663676 小时前
将 PDF 文档转换为图片【Python 教程】
python
悟空爬虫8 小时前
UV实战教程,我啥要从Anaconda切换到uv来管理包?
python
dev派8 小时前
AI Agent 系统中的常用 Workflow 模式(1)
python·langchain
明月_清风10 小时前
从“能用”到“专业”:构建生产级装饰器与三层逻辑拆解
后端·python
曲幽19 小时前
数据库实战:FastAPI + SQLAlchemy 2.0 + Alembic 从零搭建,踩坑实录
python·fastapi·web·sqlalchemy·db·asyncio·alembic
用户8356290780511 天前
Python 实现 PowerPoint 形状动画设置
后端·python
ponponon1 天前
时代的眼泪,nameko 和 eventlet 停止维护后的项目自救,升级和替代之路
python
Flittly1 天前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(5)Skills (技能加载)
python·agent