pip install matplotlib后报错:AttributeError: module 'sip' has no attribute 'setapi'的解决办法
新建虚拟环境,使用 pip install 安装各种包,使用过程中matplotlib报错:AttributeError: module ‘sip’ has no attribute ‘setapi’。
查找网上资料,有人说可以matplotlib最新版本与其它版本不兼容,需要将matplotlib降级。
pip install matplotlib==3.3.0
尝试后确实能解决问题,但分析最新版本应当可以向下兼容,应该还有其它解决方法。
于是查看报错代码位置,发现附近有这样一段代码:
if __version__ < LooseVersion("4.6"):
raise ImportError("PyQt<4.6 is not supported")
因此猜测在安装matplotlib过程中没有关联安装最新版本的pyqt包。尝试安装pyqt5:
pip install --upgrade matplotlib
pip install pyqt5
问题解决。