Cannot import QtWebKitWidgets in PyQt5

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:PYTHON35DLLs;C:PYTHON35LIB;C:PYTHON35LIBLIB-TK;

and environment path:

C:Python35Libsite-packagesPyQt5;C:Python35;C:Python35Lib;C:Python35Libsite-packages;C:Python35Scripts ....

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

You may want to switch to PyQt5.QtWebEngineWidgets :

This supercedes the QtWebKit module and provides better and up-to-date support for HTML, CSS and JavaScript features


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

链接地址: http://www.djcxy.com/p/91176.html

上一篇: 我如何在Python中编写Android应用程序?

下一篇: 无法在PyQt5中导入QtWebKitWidgets