問題描述:
這個錯誤全部顯示為: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即可
查看與當(dāng)前matplotlib版本是否匹配當(dāng)前python環(huán)境,可參考這個網(wǎng)址https://pypi.org/project/matplotlib/3.2.0/#history
應(yīng)該安裝該版本:
卸載不匹配的版本:
安裝時matplotlib版本文章來源:http://www.zghlxwxcb.cn/news/detail-457204.html
問題驗證:
重新運行:
安裝合適的低版本matplotlib,問題就解決了文章來源地址http://www.zghlxwxcb.cn/news/detail-457204.html
到了這里,關(guān)于PyCharm使用matplotlib:報MatplotlibDeprecationWarning.問題已解決的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!