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' 后端,可以在独立窗口中显示绘制的图形。
相关推荐
0白露2 小时前
关闭搜狗输入法右下角广告,可以适用于大多数应用系统通知的广告
windows·bug
一只自律的鸡15 小时前
【Linux驱动】bug处理 ens33找不到IP
linux·运维·bug
Lichenpar2 天前
Springboot采用FastJson2作为MessageConverter时,配置的全局日期类型序列化转换BUG
java·开发语言·bug
Irene19913 天前
AI 找 bug 的局限性 和 Deepseek 优势明显
bug
癫狂的兔子3 天前
【bug】【Python】pandas中的DataFrame.to_excel()和ExcelWriter的区别
python·bug
癫狂的兔子4 天前
【BUG】【Python】【Spider】Compound class names are not allowed.
开发语言·python·bug
netkiller-BG7NYT4 天前
阿里云语音合成CosyVoice重大BUG被我发现了
bug
马猴烧酒.5 天前
【Mybatis出现bug】应为 <statement> 或 DELIMITER,得到 ‘id‘
java·bug·mybatis
请叫我大虾5 天前
发现一个jdk中ArrayList的小BUG
android·java·bug
离离茶5 天前
【笔记1-10】Qt bug记录:dockwidget通过raise在最前面显示,toolbar的拓展菜单失效
笔记·qt·bug