minorua / Qgis2threejs

3D map visualization and web export plugin for QGIS
http://minorua.github.io/Qgis2threejs/docs/
507 stars 92 forks source link

ModuleNotFoundError: No module named 'PyQt5.QtWebKit' #248

Closed brandy125 closed 1 year ago

brandy125 commented 3 years ago

On Linux Suse_Tumbleweed 5.12.2-1-default #1 SMP Fri May 7 18:05:46 UTC 2021 (6fcec30) x86_64 x86_64 x86_64 GNU/Linux With Python version: 3.8.10 (default, May 05 2021, 15:36:36) [GCC] QGIS version: 3.18.2-Zürich Zürich, exported

I get the following error message when trying to enable Qgis2threejs.

How can I solve this?

kannes commented 3 years ago

Does this still happen after updating the plugin?

brandy125 commented 3 years ago

…actually it happens during the “reinstall” process:

Missing dependencies related to PyQt5 and QtWebKit. Please install "python3-pyqt5.qtwebkit" package (Debian/Ubuntu) before using this plugin.

On 25. Sep 2021, at 16:12, Hannes @.***> wrote:

Does this still happen after updating the plugin?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/minorua/Qgis2threejs/issues/248#issuecomment-927170002, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOC5K6HDNC6UB34HANSJQ7LUDYNILANCNFSM45VA3KDQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

brandy125 commented 3 years ago

Yes, still happens even after updating the plugin, just verified.

On 25. Sep 2021, at 16:12, Hannes @.***> wrote:

Does this still happen after updating the plugin?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/minorua/Qgis2threejs/issues/248#issuecomment-927170002, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOC5K6HDNC6UB34HANSJQ7LUDYNILANCNFSM45VA3KDQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

AKRFranko commented 1 year ago

Any workaround? Progress?

kannes commented 1 year ago

The plugin works perfectly fine if your Python environment has QtWebKit.

brandy125 commented 1 year ago

And if not? I mean, if I install python 3.8 there is no QtWebKit.

kannes commented 1 year ago

Then it does not. ;) Sorry for the snarkiness. My reply was for @AKRFranko's unfriendly inquiry.

One could compile PyQt5 with QtWebKit support like e.g. this Archlinux AUR package https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=python-pyqt5-webkit but I fully understand that this is not an option for most users.

@minorua has marked this issue with the label https://github.com/minorua/Qgis2threejs/labels/want%20Qt%20WebEngine so you can be sure that the main developer knows about this issue and asking won't make a difference. I am sure they would appreciate code contributions though!

brandy125 commented 1 year ago

Ok, thanks. Unfortunately I have no skills to contribute, I am just a user of this fantastic plugin.

brandy125 commented 1 year ago

Hi, I just wanted to know if there are any news about porting from Webkit to Webengine. I love this plugin so much but I have to use a special qgis version from a flatpak install to use it because my Suse Tumbleweed running aarch64 Architecture does not allow installing PyQt5 with QtWebKit support. Do you think this porting will still happen?

brandy125 commented 1 year ago

Hi everybody, is there any chance that anybody with some python knowledge can change the source code to use QtWebEngine instead of QtWebKit? As far as I understand the QtWebkit is deprecated and not used anymore in modern linux. I tried to change the code by myself but I got stuck after some lines of changes in the code.

Please, help.

brandy125 commented 1 year ago

Well, I got it almost working. The window opens and shows a blank screen. Now there are lot's of error messages like:

    self.mainFrame().evaluateJavaScript("loadJSONObject(pyData())")
    ^^^^^^^^^^^^^^
AttributeError: 'Q3DWebPage' object has no attribute 'mainFrame'

Can anybody help tp fix this?

minorua commented 1 year ago

I will start replacing Qt WebKit QWebView with Qt WebEngine QWebEngineView once QWebEngineView becomes available within QGIS. I still get the following error.

>>> from PyQt5.QtWebEngineWidgets import *
ImportError: QtWebEngineWidgets must be imported or Qt.AA_ShareOpenGLContexts must be set before a QCoreApplication instance is created

QGIS 3.32.0, openSUSE Tumbleweed on WSL

brandy125 commented 1 year ago

Hi @minorua, thanks for having a look to it.

Actually I think the error above does not come from QWebEngineView not being available withing QGIS as it actually is already:

# Python Console
# Use iface to access QGIS API interface or type '?' for more info
# Security warning: typing commands from an untrusted source can harm your computer
>>> from PyQt5.QtWebEngineWidgets import *
>>> from PyQt5.QtWebEngineWidgets import QWebEngineView

I think the error message comes because if using QWebEngine there must be changed something else in the very beginning of the program. Could you please try it again?

kannes commented 1 year ago

@brandy125 are you sure that you don't get a red error bar (or stacktrace on stderr) when you do that? If not, what's your QGIS setup?

https://github.com/qgis/QGIS/issues/26048#issuecomment-569353410

There's no way this can be solved in qgis -- qgis has to create an application before python support is setup. There's no way around that. The fix for this would be to work with upstream and get a workaround implemented which would avoid the need to initialise before the application construction.

https://github.com/qgis/QGIS/issues/49512#issuecomment-1244676849

This is expected -- it's currently completely impossible to use both QtWebEngine AND Qt 3D in the one application, and unfortunately QGIS 3D is based on Qt 3D. So there's no way to use webengine at ALL in QGIS right now.

minorua commented 1 year ago

@brandy125 Thanks : )

I have successfully displayed a web page exported using this plugin in a web view of QWebEngineView within QGIS.

OS: openSUSE Tumbleweed on WSL QGIS Code: jbp35's qgs3dwindow branch rebased on current master

In Python Console:

import os
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView

os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--ignore-gpu-blocklist --enable-gpu-rasterization"

url = "https://qgis2threejs-examples-24.netlify.app/mt_fuji.html"

view = QWebEngineView()
view.load(QUrl(url))
view.show()
brandy125 commented 12 months ago

Hi @minorua thank you very much for working again on your plugin.

I saw your new version and installed it on my system

Linux localhost.localdomain 6.2.9-1-default #1 SMP PREEMPT_DYNAMIC Thu Mar 30 11:30:50 UTC 2023 (7a187a3) aarch64 aarch64 aarch64 GNU/Linux
NAME="openSUSE Tumbleweed"
# VERSION="20231003"

but it does not work for me. If I let

# 3D view
PREFER_WEBKIT = True

in the file conf.py then qgis complains with

ImportError: libQt5WebKitWidgets.so.5: cannot open shared object file: No such file or directory

If I set

# 3D view
PREFER_WEBKIT = False

Then I get the following error message:

ImportError: QtWebEngineWidgets must be imported or Qt.AA_ShareOpenGLContexts must be set before a QCoreApplication instance is created

Is this new version meant to work already on my system or is it still "in preparation"? I am asking, because you closed this issue and for me it is not working yet.

But anyway, thank you very much already for your work.

minorua commented 12 months ago

@brandy125 I needed to build QGIS myself on Tumbleweed to get QWebEngineView to work in QGIS. It didn't work on Ubuntu 22.04. Thanks.

OS: openSUSE Tumbleweed on WSL QGIS Code: jbp35's qgs3dwindow branch rebased on current master

EDIT: Web engine view works in self-build QGIS on Ubuntu 23.04 on WSL.