3

When installing the plugin qgis2web through the plugin manager on the qgis 2.99 nightly release I get the following error message. Does anyone know what I need to do to get it working. I've not seen an obvious corresponding issue on the github repo.

Couldn't load plugin 'qgis2web' due to an error when calling its classFactory() method 

ImportError: No module named 'PyQt5.QtWebKitWidgets' 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 336, in startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/home/will/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/__init__.py", line 28, in classFactory
    from .qgis2web import Qgis2Web
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 664, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/will/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/qgis2web.py", line 30, in 
    from qgis2web.maindialog import MainDialog
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 664, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/will/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/maindialog.py", line 55, in 
    from qgis.PyQt.QtWebKitWidgets import QWebView, QWebInspector, QWebPage
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 664, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/lib/python3/dist-packages/qgis/PyQt/QtWebKitWidgets.py", line 26, in 
    from PyQt5.QtWebKitWidgets import *
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 664, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named 'PyQt5.QtWebKitWidgets'


Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] 
QGIS version: 2.99.0-Master Master, 585a4d3 

Python Path:
/home/will/.local/share/QGIS/QGIS3/profiles/default/python/plugins/gml_application_schema_toolbox/extlibs
/usr/share/qgis/python
/home/will/.local/share/QGIS/QGIS3/profiles/default/python
/home/will/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python35.zip
/usr/lib/python3.5
/usr/lib/python3.5/plat-x86_64-linux-gnu
/usr/lib/python3.5/lib-dynload
/home/will/.local/lib/python3.5/site-packages
/usr/local/lib/python3.5/dist-packages
/usr/lib/python3/dist-packages
/home/will/.local/share/QGIS/QGIS3/profiles/default/python
  • 1
    Did you check if you have PyQt5 installed? – Piskr Feb 23 '18 at 13:14
  • I can run import PyQt 5 in the python console, but import PyQt 5.QtWebKitWidgets throws and error. – RoperMaps Feb 23 '18 at 16:38
5

The missing module is 'PyQt5.QtWebKitWidgets' which can be installed on ubuntu as part of the 'python3-pyqt5.qtwebkit' deb package.

To check if it is already installed, and ensure it is available, the command is:

apt-cache policy python3-pyqt5.qtwebkit

Assuming it isn't installed, then it can be installed with:

sudo apt install python3-pyqt5.qtwebkit

Thanks to Tom Chadwin for pointing me on the right track.

2

I don't know what distribution you are on, but this is likely to be the availability of QtWebkit, or its Python bindings. See if you can ensure they are installed.

  • Thanks Tom. Should this be as part of the qgis install, or should they be somewhere separate? When you say 'distribution' do you mean of qgis2web? – RoperMaps Feb 23 '18 at 16:39
  • I believe he<s referring to your Linux distribution or your OS. It may be the case that Ubuntu/CentOS/etc. doesn't include the latest version of QtWebkit5 or include more recent Python bindings for it. This is particularly true for LTS distributions (e.g. Ubuntu Xenial or Debian Jessie). – Trevor J. Smith Feb 23 '18 at 16:55
  • Thanks! Slow going with QGIS on ubuntu so appreciate the help. I'm on Ubuntu Xenial, I installed QGIS with http://qgis.org/ubuntugis-nightly xenial main and http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu xenial main ppa repositories. So assumed they handled dependencies. How would I check for the QtWebKit5/it's python bindings? – RoperMaps Feb 23 '18 at 17:26
  • Ok, so this was it. After briefly breaking everything by trying to use pip to install the qtwebkit (bad idea), I settled on $ apt-cache policy python3-pyqt5.qtwebkit to check if it was installed and then $ sudo apt install python3-pyqt5.qtwebkit. I have edited the answer to include these steps. – RoperMaps Feb 24 '18 at 14:50
  • So my edit was rejected, which is fine, but perhaps @Tom Chadwin you might want to include those steps. It wasn't immediately obvious to me how to follow your advice as a linux novice. – RoperMaps Feb 24 '18 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.