我正在使用Python 3和PyQt5开发一个小型图形应用程序.在我使用的第一台计算机上,只安装了PyQt5,我的代码中的所有内容都很好.但是当我想在我的其他笔记本电脑上运行我的代码时,安装了PyQt4和PyQt5,我收到以下错误:
RuntimeError: the PyQt5.QtCore and PyQt4.QtCore modules both wrap the QObject class
Run Code Online (Sandbox Code Playgroud)
Python解释器将错误定位在从主文件调用的文件"ViewWindow.py"中.
因为我在这台笔记本电脑上有PyQt4和PyQt5,并且因为我无法卸载PyQt4(这太简单了......),我想知道是否有可能强制使用PyQt5.QtCore或其他东西来避免这个问题.我在这台笔记本电脑上的配置:Debian 8,Python3.4,PyQt4和5(没有特殊配置,从Debian repos安装),IDE = Spyder.
我把我的文件有第一线main.py和ViewWindow.py.
# main.py
import sys
import sqlite3
import ViewWindow
from DataWindow import DataWindow
from PyQt5.QtCore import QObject # I tried adding this line, but nothing changed...
from PyQt5.QtWidgets import (QApplication,
QWidget,
QGridLayout,
QHBoxLayout,
QLabel,
QLineEdit,
QPushButton,
QTextEdit,
QVBoxLayout
)
class MainWindow(QWidget):
# Some cool stuff
# ViewWindow.py
import sys
import sqlite3
from PyQt5.QtCore import QObject # same …Run Code Online (Sandbox Code Playgroud)