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' 后端,可以在独立窗口中显示绘制的图形。
相关推荐
癫狂的兔子1 小时前
【bug】【Python】pandas中的DataFrame.to_excel()和ExcelWriter的区别
python·bug
癫狂的兔子21 小时前
【BUG】【Python】【Spider】Compound class names are not allowed.
开发语言·python·bug
netkiller-BG7NYT1 天前
阿里云语音合成CosyVoice重大BUG被我发现了
bug
马猴烧酒.2 天前
【Mybatis出现bug】应为 <statement> 或 DELIMITER,得到 ‘id‘
java·bug·mybatis
请叫我大虾2 天前
发现一个jdk中ArrayList的小BUG
android·java·bug
离离茶2 天前
【笔记1-10】Qt bug记录:dockwidget通过raise在最前面显示,toolbar的拓展菜单失效
笔记·qt·bug
测试_AI_一辰2 天前
Agent & RAG 测试工程笔记 01:Tool Calling 跑通 + 本地 PDF 接入(智谱 GLM)
人工智能·笔记·功能测试·自动化·bug
癫狂的兔子2 天前
【BUG】【Python】清除字符串空格问题
bug
癫狂的兔子4 天前
【BUG】【Python】【爬虫】爬取加载中的数据
爬虫·python·bug
wangsir.5 天前
测试之BUG篇
bug·测试