29

I've recently upgraded PyQt5 from 5.5.1 to 5.6.0 using the Windows 32-bit installer here: https://www.riverbankcomputing.com/software/pyqt/download5. I've also upgraded my python from 3.4 to 3.5.

When I run my old code (which used to work) with the latest version I get an exception:

    from PyQt5.QtWebKitWidgets import *
ImportError: No module named 'PyQt5.QtWebKitWidgets'

All of my QT calls in my python occur consecutively and are (and I know I shouldn't be importing * but that's beside the issue here I think):

        from PyQt5.QtCore import *
        from PyQt5.QtGui import *
        from PyQt5.QtWidgets import *
        from PyQt5.QtWebKitWidgets import *

So the QtCore, QtGui and QtWidgets imports are all OK.

Also, when I search the source for QtWebKitWidgets there appears several references to this module.

Finally my python path looks like:

C:\PYTHON35;C:\PYTHON35\DLLs;C:\PYTHON35\LIB;C:\PYTHON35\LIB\LIB-TK;

and environment path:

C:\Python35\Lib\site-packages\PyQt5;C:\Python35;C:\Python35\Lib;C:\Python35\Lib\site-packages;C:\Python35\Scripts ....
Jibbity jobby
  • 1,255
  • 2
  • 12
  • 26

5 Answers5

35

QtWebKit got deprecated upstream in Qt 5.5 and removed in 5.6.

You may want to switch to PyQt5.QtWebEngineWidgets.QWebEngineView.

For basic use of PyQt5.QtWebKitWidgets.QWebView, it can simply be updated to use PyQt5.QtWebEngineWidgets.QWebEngineView in the source code, but there may be some differences in the new component which require further adjustments.

John Vandenberg
  • 474
  • 6
  • 16
IAmInPLS
  • 4,051
  • 4
  • 24
  • 57
  • Thank you very much, I did not know it had been deprecated. This is probably a different question but I had tried replacing the import with QtWebEngineWidgets but got another error: from PyQt5.QtWebEngineWidgets import * ImportError: DLL load failed: The operating system cannot run %1. I'm initially guessing a different bit type... but I did run the correct installer (both python and qt 32 bit on 64 bit system). – Jibbity jobby Jun 17 '16 at 09:01
  • 3
    I think you can ask a new question for this error :) or look at answers like this one http://stackoverflow.com/questions/22800768/getting-error-dll-load-failed-the-operating-system-cannot-run-1-python-2-7 – IAmInPLS Jun 17 '16 at 09:07
  • 1
    I got it working by installing PyQtWebEngine: https://stackoverflow.com/questions/33108133/how-to-build-qt-webengine-for-pyqt5/55363933#55363933 – Ehvince Mar 28 '19 at 11:34
  • If i want to downgrade pyinstaller which version should i use? i ask because msys mingw64 doesn't support PyQtWebEngine – Chris P Apr 24 '21 at 08:25
25

I was trying to run qutebrowser and it had the same error, the answer is simple, the packages changed. You have two solutions:

1)

pip install PyQtWebEngine

2)

pip install PyQt5==5.11.3

Hope this helps any future problems

phrogg
  • 888
  • 1
  • 13
  • 28
Spounka
  • 444
  • 6
  • 12
15

In PyQt5 "QtWebKitWidgets" is Deprecated. I just replace this line

from PyQt5.QtWebKitWidgets import QWebView, QWebPage
from PyQt5.QtWebKit import QWebSettings

With this code:

from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView,QWebEnginePage as QWebPage
from PyQt5.QtWebEngineWidgets import QWebEngineSettings as QWebSettings
Anonymous
  • 738
  • 4
  • 14
  • 36
Istiyak
  • 693
  • 6
  • 15
4

In PyQt5 "QtWebKitWidgets" is no longer available. Instead it is replaced with "QtWebEngineWidgets". So you have to make this change in your code.

For more information: http://doc.qt.io/qt-5/qtwebenginewidgets-qtwebkitportingguide.html

SilverRayX
  • 41
  • 2
4

If you really want to use PyQt5.QtWebKitWidgets, you could run this from the command line:

pip install PyQtWebKit

and let it do what it does.

Sid
  • 2,174
  • 1
  • 13
  • 29
  • 5
    ```ERROR: Could not find a version that satisfies the requirement PyQtWebKit ERROR: No matching distribution found for PyQtWebKit``` – Sterling Feb 25 '21 at 22:54