Bug--python画图

今天在画图的时候遇见了bug:

python 复制代码
import matplotlib.pyplot as plt

AttributeError: partially initialized module 'matplotlib.backends.backend_macosx' has no attribute 'FigureCanvas' (most likely due to a circular import)

原因:

画图的时候后端显示不正常,没有正常模块显示。

解决:

python 复制代码
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
  • matplotlib.use('TkAgg') 这行代码指定了 Matplotlib 使用 'TkAgg' 后端。后端是 Matplotlib 用来绘制图像的引擎或框架。
  • 'TkAgg' 是基于 Tkinter 的后端,Tkinter 是 Python 的标准 GUI(图形用户界面)工具包。使用 'TkAgg' 后端,可以在独立窗口中显示绘制的图形。
相关推荐
callJJ4 天前
Volta + Claude Code 在 Windows 上的路径 Bug 复盘
windows·bug
xsc-xyc5 天前
记一次RK3568搭建NAS BUG:开发板插上 USB 移动硬盘没反应
bug
放风铃的兔子6 天前
我把 5 个 Python bug 投进 CubeSandbox 当沙盘 —— 从 envd 协议反编译到一键 RED→GREEN
bug·issue
zh_xuan7 天前
诡异Bug:输入框删除字符,却越删越多
android·bug
绘梨衣5477 天前
采集基类设计遇到的描述符bug
爬虫·python·bug
不吃鱼的羊7 天前
达芬奇工具Bug
bug
油炸自行车8 天前
【bug】Qt 6 Q_NAMESPACE 跨 DLL 链接错误:LNK2019 无法解析 staticMetaObject
数据库·c++·qt·bug·link2019·q_namespace_exp·namespaceexport
sxd20019 天前
Debian #1135514 bug引发的思考
网络·debian·bug
疏狂难除10 天前
X86-64 Assembly中printf 打印 float 和 double的bug的解决
bug·assembly
nashane12 天前
HarmonyOS 6学习:指南针“文图反向”Bug修复——从“北偏东”变“北偏西”的坐标系纠错
学习·华为·bug·harmonyos