In order to avoid unexpected errors during installation,be sure to install the packages metioned here.This prevents you encounter the same trouble as me.
yum install python-devel yum install gcc-c++ yum install qt-devel yum install qt-config
Aaddress: PyQt4 and SIP
We need to download two files:Pyqt4 and SIP
Extract the SIP package and cd into the folder.
python configure.py make && make install
Extarct the PyQt4 package and cd into the folder.
python configure.py -k /usr/lib/qt4/ make ldconfig make install
1.If you get following error message during Pyqt installation,be sure to install qt-devel and qt-config
2.Or you will get this message
Please excute `ldconfig` before make install.
After installation,we can use this script to test.
#!/usr/bin/env python # -*- coding:utf-8-*- import sys import from PyQt4.QtGui import * class TestWidget(QWidget): def __init__(self): Qwidget.__init__(self,windowTitle=u"A Simple Example for PyQt.") self.outputArea=QTextBrowser(self) self.helloButton=QPushButton(self,trUtf8("hellow(&s)"),self) self.layout().addWidget(self.outputArea) self.layout().addWidget(self.helloButton) self.helloButton.clicked.connect(self.sayHello) def sayHello(self): yourName,okay=QInputDialog.getText(self,self,trUtf8("Your name:"),self.trUtf8(b"name")) if not okay or yourName==u"": self.outputArea.append(self.trUtf8("Hello,new guy!")) else: self.outputArea.append(self.trUtf8("Hello,<\b>%1<\b>.").arg(yourname)) app=QApplication(sys.argv) testWidget=TestWidget() testWidget.show() sys.exit(app.exec_())
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
You need to delete the '\' in '<\b>'