我正在使用Centos7并使用Python 3.3.2。 我试图运行使用PyQt4模块的Python脚本,但我收到了这个错误:
ImportError: No module named 'PyQt4'
脚本还没有完整的功能,但我只是想确保它运行并且可以在这个早期阶段访问正确的模块等,因为我是新手蟒蛇。到目前为止,这是脚本:
#!/usr/bin/env python3
from PyQt4 import QtCore, QtGui
from os.path import expanduser
import os
import shlex
#import Converted Python UI File
from mainwindow import Ui_MainWindow
class Main(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
# Connect the Buttons
QtCore.QObject.connect(self.ui.selectFileButton,QtCore.SIGNAL("clicked()"),self.selectFile)
QtCore.QObject.connect(self.ui.convertButton,QtCore.SIGNAL("clicked()"),self.convert)
def selectFile(self):
fileName = QtGui.QFileDialog.getOpenFileName(self,'Open Media File',expanduser("~"),'Media Files (*.mov *.avi *.mkv *.mpg)')
self.ui.fileName.setText(fileName)
def convert(self):
self.convertFile()
def main():
app = QtGui.QApplication(sys.argv)
window = Main()
window.show()
sys.exit(app.exec_())
#if __name__ == “__main__”:
main()
我肯定安装了PyQt。
当我跑步时:
rpm -ql PyQt4
它产生这样的东西:
/usr/lib64/python2.7/site-packages/PyQt4
/usr/lib64/python2.7/site-packages/PyQt4/Qt.so
/usr/lib64/python2.7/site-packages/PyQt4/QtCore.so
/usr/lib64/python2.7/site-packages/PyQt4/QtDBus.so
/usr/lib64/python2.7/site-packages/PyQt4/QtDeclarative.so
/usr/lib64/python2.7/site-packages/PyQt4/QtDesigner.so
/usr/lib64/python2.7/site-packages/PyQt4/QtGui.so
/usr/lib64/python2.7/site-packages/PyQt4/QtHelp.so
/usr/lib64/python2.7/site-packages/PyQt4/QtMultimedia.so
/usr/lib64/python2.7/site-packages/PyQt4/QtNetwork.so
/usr/lib64/python2.7/site-packages/PyQt4/QtOpenGL.so
/usr/lib64/python2.7/site-packages/PyQt4/QtScript.so
/usr/lib64/python2.7/site-packages/PyQt4/QtScriptTools.so
/usr/lib64/python2.7/site-packages/PyQt4/QtSql.so
/usr/lib64/python2.7/site-packages/PyQt4/QtSvg.so
/usr/lib64/python2.7/site-packages/PyQt4/QtTest.so
/usr/lib64/python2.7/site-packages/PyQt4/QtXml.so
/usr/lib64/python2.7/site-packages/PyQt4/QtXmlPatterns.so
/usr/lib64/python2.7/site-packages/PyQt4/__init__.py
/usr/lib64/python2.7/site-packages/PyQt4/__init__.pyc
/usr/lib64/python2.7/site-packages/PyQt4/__init__.pyo
/usr/lib64/python2.7/site-packages/PyQt4/phonon.so
/usr/lib64/python2.7/site-packages/PyQt4/pyqtconfig.py
/usr/lib64/python2.7/site-packages/PyQt4/pyqtconfig.pyc
/usr/lib64/python2.7/site-packages/PyQt4/pyqtconfig.pyo
/usr/lib64/python2.7/site-packages/PyQt4/uic
/usr/lib64/python2.7/site-packages/PyQt4/uic/Compiler
这表明安装了PyQt以与Python2一起使用。我怎样才能纠正这个问题,以便它适用于Python 3.3.2?
我试过yum install python-pyqt4
但是在Centos上似乎没有可用的套餐。有什么想法吗?
由于