运行以下代码时出现以下错误。
无法将不兼容的Qt库(版本0x50c05)与此库(版本0x50d02)混合在一起
如何调试?
import sys
import random
from PySide2 import QtCore, QtWidgets, QtGui
class MyWidget(QtWidgets.QWidget):
def __init__(self):
super().__init__()
self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]
self.button = QtWidgets.QPushButton("Click me!")
self.text = QtWidgets.QLabel("Hello World")
self.text.setAlignment(QtCore.Qt.AlignCenter)
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.text)
self.layout.addWidget(self.button)
self.setLayout(self.layout)
self.button.clicked.connect(self.magic)
def magic(self):
self.text.setText(random.choice(self.hello))
if __name__ == "__main__":
app = QtWidgets.QApplication([])
widget = MyWidget()
widget.resize(800, 600)
widget.show()
sys.exit(app.exec_())
问题是,我使用的是conda-forge的qt 5.12.5,使用的是pip wheel(https://github.com/conda-forge/conda-forge.github.io/issues/921#issuecomment-553094850)的pyqt。
最后,我摆脱了如下烦人的错误: