解决matplotlib突然出现SystemError: initialization of QtCore failed without raising an exception错误

SystemError: initialization of QtCore failed问题

问题描述

在使用matplotlib绘图时,原来好好的可以正常运行,但是在某一次运行过程中突然出现SystemError: initialization of QtCore failed without raising an exception的错误。
代码如下:

from matplotlib import pyplot as plt
# 可视化图像的函数
def look_img(img):
    img_rgb = cv.cvtColor(img, cv.COLOR_BGR2RGB)
    plt.imshow(img_rgb)
    plt.show()

在这里插入图片描述

解决方案

使用pip list查看安装的库发现确实没有PyQt5这个库,于是就安装一下

pip install PyQt5

安装完了之后matplotlib果然就能正常使用了。
奇怪的是之前一直没有安装PyQt5这个库matplotlib也运行得好好的,但是今天就突然出错了。

猜你喜欢

转载自blog.csdn.net/m0_57110410/article/details/125582808