【问题标题】:RuntimeError when importing PyQt5导入 PyQt5 时出现 RuntimeError
【发布时间】:2016-09-26 23:20:50
【问题描述】:

我现在正在学习 PyQt5

当我尝试运行以下代码时

from PyQt5.QtWidgets import QApplication

我犯了错误

Traceback (most recent call last):
File "<ipython-input-10-0ebe4054b7ae>", line 1, in <module>
from PyQt5.QtWidgets import QApplication
RuntimeError: the PyQt5.QtCore and PyQt4.QtCore modules both wrap the QObject class

那怎么了?谢谢帮忙!

【问题讨论】:

标签: python pyqt5


【解决方案1】:

问题是 Matplotlib 使用 QT5 而您使用的是 QT4。为了解决这个问题,你可以强制 Matplotlib 使用 QT4,通过编辑 matplotlibrc,它位于 \Lib\site-packages\matplotlib\mpl-data

在我的例子中是 matplotlib

【讨论】:

    【解决方案2】:

    This 解决了我的问题:

    你可以去 Settings>Build,Execution,Deployment>Debugger>Python Debugger>PyQt compatible: 选择 PyQt4。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-02
      • 2020-10-25
      • 2020-08-12
      • 2022-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多