PyCharm使用matplotlib:报MatplotlibDeprecationWarning.问题已解决

问题描述:

这个错误全部显示为:MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later.
报错截图如下所示:
代码示例:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 10, 0.1)
y = np.sin(x)
plt.plot(x, y)
plt.show()
plt.plot(x, y, ‘r’, label=‘sin(x)’)
plt.xlabel(‘x’)
plt.ylabel(‘y’)
plt.title(‘Sin Wave’)
plt.legend()
plt.show()

原因定位:

使用了过高版本的matplotlib库

查看matplotlib库版本信息

问题解决

安装低版本matplotlib即可
查看与当前matplotlib版本是否匹配当前python环境,可参考这个网址https://pypi.org/project/matplotlib/3.2.0/#history
应该安装该版本:

卸载不匹配的版本:

安装时matplotlib版本

问题验证:

重新运行:

安装合适的低版本matplotlib,问题就解决了

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年5月26日
下一篇 2023年5月26日

相关推荐