我正在使用CentOS5系统。我通过make altinstall安装了Python26源代码。然后我执行了以下操作:
yum install qt4
yum install qt4-devel
yum install qt4-doc
我从riverbankcomputing.co.uk下载了sip 4.10.2的源代码,并成功编译和安装。然后我从同一网站下载并编译了PyQt-x11-4.7.3的源代码。
这两个安装都使用了python26版本(/usr/local/bin/python2.6)。因此,configure.py、make和make install都没有出现错误。最后,我尝试运行这个脚本,但是出现了这篇文章标题中的错误:
import sys
import signal
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import QWebPage
def onLoadFinished(result):
if not result:
print "Request failed"
sys.exit(1)
#screen = QtGui.QDesktopWidget().screenGeometry()
size = webpage.mainFrame().contentsSize()
# Set the size of the (virtual) browser window
webpage.setViewportSize(webpage.mainFrame().contentsSize())
# Paint this frame into an image
image = QImage(webpage.viewportSize(), QImage.Format_ARGB32)
painter = QPainter(image)
webpage.mainFrame().render(painter)
painter.end()
image.save("output2.png")
sys.exit(0)
app = QApplication(sys.argv)
signal.signal(signal.SIGINT, signal.SIG_DFL)
webpage = QWebPage()
webpage.connect(webpage, SIGNAL("loadFinished(bool)"), onLoadFinished)
webpage.mainFrame().load(QUrl("http://www.google.com"))
sys.exit(app.exec_())
即使在pyqt4的配置开始时,我看到它说QtWebKit应该被安装,但显然它没有被安装?发生了什么事?
我刚才进行了查找,看起来它没有被安装。我的选择是什么?
[root@localhost ~]# find / -name '*QtWebKit*'
/root/PyQt-x11-gpl-4.7.3/sip/QtWebKit
/root/PyQt-x11-gpl-4.7.3/sip/QtWebKit/QtWebKitmod.sip
/root/PyQt-x11-gpl-4.7.3/cfgtest_QtWebKit.cpp