今天在画图的时候遇见了bug:
- import matplotlib.pyplot as plt
复制代码 AttributeError: partially initialized module 'matplotlib.backends.backend_macosx' has no attribute 'FigureCanvas' (most likely due to a circular import)
原因:
画图的时候后端表现不正常,没有正常模块表现。
解决:
- import matplotlib
- matplotlib.use('TkAgg')
- import matplotlib.pyplot as plt
复制代码
- matplotlib.use('TkAgg') 这行代码指定了 Matplotlib 使用 'TkAgg' 后端。后端是 Matplotlib 用来绘制图像的引擎或框架。
- 'TkAgg' 是基于 Tkinter 的后端,Tkinter 是 Python 的标准 GUI(图形用户界面)工具包。使用 'TkAgg' 后端,可以在独立窗口中表现绘制的图形。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |