Python 2.7.11 - ImportError: cannot import name QtWebKit - Kali Linux / Debian 8

13,327

This is an issue with the app, sparta?. Debian Stretch which Kali Rolling is based on has mothballed QtWebKit in PyQt4.

The latest version does not contain QtWebkit.so.

Unfortunately the code in question needs to be updated to use an alternative such as PyQt5 equivalent module.

A bug report concerning this can be found on the kali bug report site from Jun/2/2016


optional bodge/quick n dirty fix [works in latest build of Kali]

In the mean time and if it is sparta and you need it functional now:
apt-get install python-pyside.qtwebkit
clone a copy from https://github.com/SECFORCE/sparta to where ever suits, in my case /opt/recon/sparta, this preserves the system version so it can fixed updated normally.
edit sparta.py

remove QtWebKit from line 22
insert the code from line 26 to 30

21 try: 
22    from PyQt4 import QtGui, QtCore
23 except:
24    print "[-] Import failed. PyQt4 library not found. \nTry installing it with: apt-get install python-qt4"
25    exit()
26 try:
27    from PySide import QtWebKit
28 except:
29    print "[-] Import failed. QtWebkit library not found. \nTry installing it with: apt-get install python-pyside.qtwebkit"
30    exit()

edit ui/view.py
comment out line 15

15 #from PyQt4 import QtWebKit                                              # to show html code (help menu)
16 from PySide import QtWebKit                                              # to show html code (help menu)

edit line 54 the original can be seen below

54 self.helpWidget.load(QUrl('./doc/help.html'))

This should be modified to

54 self.helpWidget.load('./doc/help.html')  

Disclaimer This is a 5 minute fix, look to the project homepage for longterm fix.

Share:
13,327
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm trying to launch an app dependant on QtWebKit but i'm unable to import the module. I've tried debugging by launching python and importing other modules. They all work fine (e.g. from PyQt4 import QtGui, QtCore) works without any issues, but when i run

    from PyQt4 import QtGui, QtCore, QtWebKit
    

    I receive the following:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: cannot import name QtWebKit
    

    I have also tried the following to no avail (they install fine but do not fix the issue):

    apt-get install --reinstall python-qt4
    apt-get install --reinstall python-2.7