D:\jiqixuexi\main.py:64: 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.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc) Traceback (most recent call last): File "D:\jiqixuexi\main.py", line 64, in <module> plt.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc) File "D:\2023.5.21\lib\site-packages\matplotlib\pyplot.py", line 2785, in plot return gca().plot( File "D:\2023.5.21\lib\site-packages\matplotlib\pyplot.py", line 2282, in gca return gcf().gca() File "D:\2023.5.21\lib\site-packages\matplotlib\pyplot.py", line 879, in gcf return figure() File "D:\2023.5.21\lib\site-packages\matplotlib\_api\deprecation.py", line 454, in wrapper return func(*args, **kwargs) File "D:\2023.5.21\lib\site-packages\matplotlib\pyplot.py", line 813, in figure manager = new_figure_manager( File "D:\2023.5.21\lib\site-packages\matplotlib\pyplot.py", line 382, in new_figure_manager _warn_if_gui_out_of_main_thread() File "D:\2023.5.21\lib\site-packages\matplotlib\pyplot.py", line 360, in _warn_if_gui_out_of_main_thread if _get_required_interactive_framework(_get_backend_mod()): File "D:\2023.5.21\lib\site-packages\matplotlib\pyplot.py", line 208, in _get_backend_mod switch_backend(rcParams._get("backend")) File "D:\2023.5.21\lib\site-packages\matplotlib\pyplot.py", line 331, in switch_backend manager_pyplot_show = vars(manager_class).get("pyplot_show") TypeError: vars() argument must have __dict__ attribute
时间: 2023-08-07 18:02:57 浏览: 109
这个错误提示是由于你的程序调用了Matplotlib中已经弃用的FigureCanvas函数。你可以尝试更新Matplotlib版本或者修改代码中调用FigureCanvas的部分。此外,还有一些其他的错误提示,比如TypeError: vars() argument must have __dict__ attribute,这可能是由于你在使用vars()函数时传入了一个没有__dict__属性的对象导致的。你可以检查一下你的代码,查找是否存在这样的情况。
相关问题
/Users/dujun/opt/anaconda3/bin/python /Users/dujun/PycharmProjects/pythonProject1/main.py /Users/dujun/PycharmProjects/pythonProject1/main.py:4: 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.figure("results_img", figsize=(26,26)) /Users/dujun/PycharmProjects/pythonProject1/main.py:6: 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.show() 进程已结束,退出代码0
这个警告是由于Matplotlib库的版本升级导致的,它在3.6版本中引入了一个新的属性`required_interactive_framework`,并且将在未来的版本中删除不带该属性的FigureCanvases。
虽然这个警告可以忽略,但如果你想避免它,可以尝试更新Matplotlib库到最新版本。你可以使用以下命令来更新Matplotlib库:
```
pip install --upgrade matplotlib
```
如果你已经安装了最新版本的Matplotlib库,但仍然收到警告,请检查你的代码是否在其他地方使用了不再支持的特性或函数。
请注意,这个警告不会影响你的代码的运行,你可以继续进行开发和测试。如果你有其他问题,请随时提问。
D:\pythonProject1\main.py:144: 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(cm, cmap=plt.cm.Blues) D:\pythonProject1\main.py:154: 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.show() Traceback (most recent call last): File "D:\pythonProject1\main.py", line 185, in <module> y_true = y_test[np.arange(y_test.shape[0]), y.astype(str)] IndexError: arrays used as indices must be of integer (or boolean) type是什么意思,该如何修改
这个错误信息提示了两个问题:
1. MatplotlibDeprecationWarning:这是Matplotlib库中的一个警告,意味着你正在使用过时的方法来创建图形。它不是错误,但是建议你更新代码以使用新的方法来创建图形。
2. IndexError:这是一个错误,可能是由于使用了错误类型的索引。在你的代码中,你正在使用`y.astype(str)`创建一个字符串类型的数组,并将其用作索引,但是你不能使用字符串类型的数组作为索引。索引必须是整数或布尔类型。
为了解决这些问题,建议你更新Matplotlib库并使用整数或布尔类型的索引。你可以使用`int()`或`bool()`函数将数组转换为整数或布尔类型的索引。另外,也可以使用`np.array()`函数创建一个整数或布尔类型的索引数组。
阅读全文
相关推荐












