Nathan Nathan - 8 months ago 140
Python Question

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 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, 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"

#screen = QtGui.QDesktopWidget().screenGeometry()
size = webpage.mainFrame().contentsSize()
# Set the size of the (virtual) browser window

# Paint this frame into an image
image = QImage(webpage.viewportSize(), QImage.Format_ARGB32)
painter = QPainter(image)

app = QApplication(sys.argv)
signal.signal(signal.SIGINT, signal.SIG_DFL)

webpage = QWebPage()
webpage.connect(webpage, SIGNAL("loadFinished(bool)"), onLoadFinished)


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*'

Answer Source

Double check to make sure that the Qt installation on your system has the Webkit library built.

Also, check to make sure that the exists in your python2.6/site-packages/PyQt4 directory.