Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
622 views
in Technique[技术] by (71.8m points)

python - ImportError: No module named QtWebKit

I am on centos5. I installed python26 source with a make altinstall. Then I did a:

yum install qt4
yum install qt4-devel
yum install qt4-doc

From riverbankcomputing.co.uk I downloaded the source for sip 4.10.2, compiled and installed fine. Then from the same site I downloaded and compiled from source PyQt-x11-4.7.3

Both installs were using the python26 version (/usr/local/bin/python2.6). So configure.py, make, and make install worked with no errors. Finally, I tried to run this script, but got the error in the subject of this post:

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_())

Even in the beginning of the configure for pyqt4, I saw it say QtWebKit should be installed, but apparently it's not? What's going on?

I just did a find, and it looks like it wasn't installed. What are my options?

[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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

apt install python-pyqt5.qtwebkit


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...