在使用飞浆平台,练习平台上的demo:实践:手写数字识别任务,出现了下面的错误,demo地址: https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/beginner/quick_start_cn.html
报错如下:
代码语言:javascript复制E:joshuapythondemomain.py:40: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later.
plt.imshow(img[0])
Traceback (most recent call last):
File "E:joshuapythondemomain.py", line 40, in <module>
plt.imshow(img[0])
File "C:Python310libsite-packagesmatplotlibpyplot.py", line 2668, in imshow
__ret = gca().imshow(
File "C:Python310libsite-packagesmatplotlibpyplot.py", line 2282, in gca
return gcf().gca()
File "C:Python310libsite-packagesmatplotlibpyplot.py", line 879, in gcf
return figure()
File "C:Python310libsite-packagesmatplotlib_apideprecation.py", line 454, in wrapper
return func(*args, **kwargs)
File "C:Python310libsite-packagesmatplotlibpyplot.py", line 813, in figure
manager = new_figure_manager(
File "C:Python310libsite-packagesmatplotlibpyplot.py", line 382, in new_figure_manager
_warn_if_gui_out_of_main_thread()
File "C:Python310libsite-packagesmatplotlibpyplot.py", line 360, in _warn_if_gui_out_of_main_thread
if _get_required_interactive_framework(_get_backend_mod()):
File "C:Python310libsite-packagesmatplotlibpyplot.py", line 208, in _get_backend_mod
switch_backend(rcParams._get("backend"))
File "C:Python310libsite-packagesmatplotlibpyplot.py", line 331, in switch_backend
manager_pyplot_show = vars(manager_class).get("pyplot_show")
TypeError: vars() argument must have __dict__ attribute
Process finished with exit code 1
问题解决方式:
1.对pycharm编辑器进行设置
通过下面路径 File | Settings | Tools | Python Scientific
2.然后取消勾选show plots in tool window后,点击apply按钮,再点击ok按钮。
3.代码结尾加上 plt.show()后,代码就可以正常执行且不报错(注:这里的plt是我引用的别名,import matplotlib.pyplot as plt)
代码语言:javascript复制from matplotlib import pyplot as plt
plt.imshow(img[0])
plt.show()
本文为joshua317原创文章,转载请注明:转载自joshua317博客 https://www.joshua317.com/article/298