matplotlib.backends.backend_tkagg 引发“blit”属性错误

Onu*_*bek 5 python matplotlib attributeerror

当我尝试python3 module_7.py在终端上运行时,出现以下错误:

  File "/opt/CarlaSimulator/PythonClient/live_plotter.py", line 227, in plot_figure
    tkagg.blit(photo, fca.get_renderer()._renderer, colormode=2)
AttributeError: module 'matplotlib.backends.backend_tkagg' has no attribute 'blit'
Run Code Online (Sandbox Code Playgroud)

我检查了 matplotlib 安装,一切似乎都很好。使用CARLA模拟器时会出现此问题。有一些建议的修复方案,例如在 pyplot 导入之前添加 backend_tkagg 导入,但它没有解决问题。

小智 5

看来 matplotlib 改变了一些东西。根据文档,您应该使用tkagg.FigureCanvasTkAgg.blit而不是tkagg.blit(假设您import matplotlib.backends.backend_tkagg as tkagg)。