Problem with PySide6 and QtWebEngineWidgets module
-
Hi!
I recently installed PySide6 on my Linux machine, I needed a more than valid reason to finally "ditch" Python 2.7. In particular, I'm interested in handling Web content and then working with QtWebEngineWidgets.
Up to now each time I have tried to import such module I get back a "ModuleNotFoundError: No module named 'PySide6.QtWebEngineWidgets" error.
I document myself but I was not able to find a solution... just more confusion! Here some results of my investigations.From the description of the official pages it is not clear to me if QtWebEngine is installed by default:
- the availability and compatibility of Qt Web Engine with my PC is guaranteed by https://www.qt.io/product/features but it appears as "Framework Add-Ons". Does this mean that it has to be installed separately? How do I do that?
- From this page https://doc.qt.io/qtforpython-6/api.html it seems that QtWebEngineWidgets is taken for granted, but in the complete list it does not appear at all https://doc.qt.io/qtforpython-6/modules.html and in here also https://doc.qt.io/qt-6/qtmodules.html.
- I also found in the (Linux) folder with the examples '~/.local/lib/python3.8/site-packages/PySide6/examples/webenginewidgets/' but the compiler gives me an error when running one of them [see remark]. For instance just the line
from PySide6.QtWebEngineWidgets import QWebEnginePage, QWebEngineView
return me a module not found error.
Where do you find QtWebEngineWidgets and/or how do you install it? I have no idea on how to move forward... I would appreciate any kind of advice.
Thanks in advance
Remark:
# fully upgraded Linux machine
# I installad PySide6 via pip:
pip3 install PySide6
# check version (and also with some "Hallo world"-type applications)
python -c "import PySide6; from PySide6 import QtCore; print(PySide6.__version__, PySide6.QtCore.__version__)"
6.0.0 6.0.0
# import QWebEngineView
python -c "import PySide6; from PySide6 import QtWebEngineWidgets;"
ImportError: cannot import name 'QtWebEngineWidgets' from 'PySide6' (~/.local/lib/python3.8/site-packages/PySide6/__init__.py)
or
python -c "from PySide6.QtWebEngineWidgets import QWebEnginePage, QWebEngineView;"
ModuleNotFoundError: No module named 'PySide6.QtWebEngineWidgets'
# in the folder '~/.local/lib/python3.8/site-packages/PySide6/' there is no QtWebEngineWidgets file -
@cards According to Add-on support in Qt 6.0 and beyond QtWebEngine will be introduced in Qt 6.2 so since PySide6 is a Qt6 wrapper then the company will probably not provide that module until PySide6 6.2. So if you want to use QtWebEngine then you must still use PySide2.
-
Hi eyllanesc!
Thanks for your quick reply! It is with great sadness that I read your reply... Qt6.2 will be released this September/October.
By the way do you know any PySide2 doc/manual web-pages? (official and not) I have had great difficulty to find some good material to start with.
Thanks in advance
-
If we need wait for Pyside6.2 then why examples exist that use this?
"""PySide6 WebEngineWidgets Example"""
import sys
from PySide6.QtCore import QUrl
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import (QApplication, QLineEdit,
QMainWindow, QPushButton, QToolBar)
from PySide6.QtWebEngineWidgets import QWebEnginePage, QWebEngineViewSimiliar here:
https://doc.qt.io/qtforpython/examples/example_webenginequick__nanobrowser.html
https://doc.qt.io/qtforpython/examples/example_webenginewidgets__tabbedbrowser.html
https://doc.qt.io/qtforpython/examples/example_webenginewidgets__simplebrowser.htmlpython -c "import PySide6; from PySide6 import QtCore; print(PySide6.version, PySide6.QtCore.version)"
6.0.1 6.0.1python -c "import PySide6; from PySide6 import QtWebEngineWidgets;"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'QtWebEngineWidgets'Soo... 6.0.1 have this or not? Coz examples in doc reaching 6.0.1
-
-
@eyllanesc :ModuleNotFoundError: No module named 'PySide2.QtWebKitWidgets'
how can i resolve it?in ubundu 20.04,python 3.8.5