14

I try to run a python script using PyQt5 QtWebEngineWidgets but it throws errors:

  from PyQt5.QtWebEngineWidgets import (
ImportError: No module named 'PyQt5.QtWebEngineWidgets'

I think there is a package missing but which one? python3-pyqt5.qtwebkit is installed.

How to get this working?

Michael
  • 371

8 Answers8

7

I had the same issue, when trying to run Spyder for the first time. I'm using a Miniconda distribution on Mac. I had to install both so that I could lunch Spyder

pip install PyQtWebEngine
pip install PyQt5

I hope this help.

KareemJ
  • 171
7

I'm not 100% certain that this addresses the OP's error message, but at least for Ubuntu 17.04 I have successfully run:

apt-get install python3-pyqt5.qtwebengine

This brings in loads of dependencies, including libqt5webenginecore5, libqt5webenginewidgets5, python3-pyqt5.qtwebchannel and python3-pyqt5.qtwebengine.

I do not know how this relates to @The Compiler's answer of QtWebEngine not being packaged for Ubuntu, but it worked for me without any compiling of Qt/PyQt.

JonBrave
  • 699
4

The script needs QtWebEngine, not QtWebKit.

Unfortunately, that's not packaged for Debian/Ubuntu, so the only way you would get that running is to compile Qt and PyQt on your own (which can be a bit of a pain).

4

I installed python3-pyqt5.qtmultimedia

sudo apt install python3-pyqt5.qtmultimedia

in Xenial (because python3-pyqt5.qtwebengine was not found, so I searched all patterns matching python3-pyqt5 and apt-cache search found this one among others which seemed relevant to me.

I can now use ffmpegconverter again! (A small one which does great things, which I compiled by hand).

Zanna
  • 72,312
3

If you get here and are using pip - I haven't investigated fully but I just got just this when running Anki since the upgrade in pip to PyQT5 5.12. The package sizes for 5.11.3 and 5.12 are vastly different - 5.11.3 weighs in at 118MB and 5.12 at "only" 61MB. Forcing the install of 5.11.3 removed the issue. I'm guessing this is no longer bundled in the PyQT5 in pip, and needs to be installed as a separate requirement.

It's in the release notes, they moved the webengine widgets to a different package. Just run:

pip install PyQtWebEngine
barratis
  • 31
  • 2
2

If you get here and are using pip - I haven't investigated fully but I just got just this when running Anki since the upgrade in pip to PyQT5 5.12. The package sizes for 5.11.3 and 5.12 are vastly different - 5.11.3 weighs in at 118MB and 5.12 at "only" 61MB. Forcing the install of 5.11.3 removed the issue. I'm guessing this is no longer bundled in the PyQT5 in pip, and needs to be installed as a separate requirement.

pip uninstall PyQt5
pip install PyQt5==5.11.3

(Anki's requirements.txt has now been updated, so pulling the latest from Github should now work)

AntonOfTheWoods
  • 834
  • 2
  • 7
  • 15
1

I fixed it by running this command:

pip3 uninstall pyqt5

Source: https://bugs.launchpad.net/ubuntu/+source/openshot-qt/+bug/1814520

Kulfy
  • 18,154
0

If you're on Windows 10 running 64-bit version of Python 3.8.0, I found this to work:

pip uninstall PyQt5
pip uninstall PyQtWebEngine
pip install PyQt5==5.13
pip install PyQtWebEgine

Now your code will not complain about QtWebEngineWidgets import error.