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' 后端,可以在独立窗口中显示绘制的图形。
相关推荐
中冕—霍格沃兹软件开发测试10 小时前
测试工具链的构建与团队协作:从工具集成到价值流动
人工智能·科技·测试工具·开源·appium·bug
yuxuan669914 小时前
【Docker】使用docker启动禅道出现mysql.sock 文件已经存在的bug
mysql·docker·centos·bug
zfxwasaboy14 小时前
BUG: failure at drivers/pci/msi.c:376/free_msi_irqs()!
linux·c语言·bug
yscript14 小时前
GPU分配BUG: Duplicate GPU detected : rank 1 and rank 0 both on CUDA device d5000
linux·运维·服务器·vscode·bug
xiucai_cs15 小时前
【后端】开发过程中如何尽可能的减少 bug 的产生
后端·bug
大江东去浪淘尽千古风流人物15 小时前
【bug】bug记录学习,Win系统下爆栈的表现, chkstk.asm 实际是栈溢出
学习·bug
木棉知行者2 天前
【第2篇】RuntimeError: nms_impl: implementation for device cuda:0 not found.
人工智能·深度学习·bug·mmdetection
DB!!!2 天前
【bug】系统CA证书毁坏导致找不到有效的 OpenPGP 数据
bug
中冕—霍格沃兹软件开发测试2 天前
测试用例库建设与管理方案
数据库·人工智能·科技·开源·测试用例·bug
lvchaoq2 天前
解决组件不能远程搜索的问题
前端·bug