问题
I am trying to build an app in PyQt5 (version 5.6+) in Python 3.6. It contains a web browser, using QtWebEngineWidgets. It works fine on Mac, however, there are problems on Windows. When I run the code on Windows and import the module:
from PyQt5 import QtWebEngineWidgets
I get the following error:
ImportError: cannot import name 'QtWebEngineWidgets'
Now, reading some forums it looks like PyQt5.QtWebEngineWidgets is not available for Windows, yet. Is it correct? How can I have a web browser window, then?
I found online I could use QtWebKit, but according to here it seems QtWebKit was removed in Qt5.6. So what? Do I have to downgrade PyQt version?
I can't go under 5.6 in Python 3.6 anyway. Do I have to change Python version as well?
回答1:
you can try one of these solution ,
install old version :
pip install PyQt5==5.11.3
or install :
pip install PyQtWebEngine
回答2:
u can download PyQt5.6 from here: https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.6
QtWebKit got deprecated upstream in Qt 5.5 and removed in 5.6. Beacuse The QtWebEngineWidgets module is better than QtWebkit.
The example directory has many examples about QtWebEngineWidgets
来源:https://stackoverflow.com/questions/45599847/use-pyqt5-qtwebenginewidgets-on-windows-is-it-possible