1

I'm trying to create a mini web browser, but I'm having some problems with PyQtWebEngine. When I run the code the window appear but It's blank, that window don't show me the page (In this case of test I'm trying to connect with Google).

I've already tried to reinstall PyQt5, PyQtWebEngine and I've already create a Virtual Enviroment with venv (as I see here) but seems that nothing could fix it.

I run the code with debug mode with F5 and run using QT_DEBUG_PLUGINS=1 but they show me no errors.

This is the code (I'm just following this example)

import sys
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import QApplication

app = QApplication(sys.argv)
web = QWebEngineView()
web.load(QUrl('https://google.it/'))
web.show()


sys.exit(app.exec_())

And this is the window when I run the code stoopid code with stoopid window

I'm editing this code with Microsoft Visual Code, running on Ubuntu 22.04.1.

  • I tested it on Linux Mint 21 (based on Ubuntu 22.04) and it also doesn't display. I tested also examples with some tutorials and they also don't work. I would say - they load something but they don't display it - for some moment I can only see white page. – furas Sep 27 '22 at 16:19
  • [python 3.x - PyQt5 QWebEngineView does not show webpage - Stack Overflow](https://stackoverflow.com/questions/72346850/pyqt5-qwebengineview-does-not-show-webpage) – furas Sep 27 '22 at 21:02
  • [python - Unable to render webpage using QWebEngineView - Stack Overflow](https://stackoverflow.com/questions/70988870/unable-to-render-webpage-using-qwebengineview/72422626#72422626) – furas Sep 27 '22 at 21:02

1 Answers1

1

I got the same problem with your code on Linux Mint 21 (based on Ubuntu 22.04).
Even other examples from tutorials had the same problem.

this answer helped me to resolve this problem. I describe it with more details.


I got all installed modules for PyQt5

pip3 freeze | grep -i pyqt
PyQt5==5.15.7
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.0
PyQtWebEngine==5.15.6
PyQtWebEngine-Qt5==5.15.2

and I unistalled all of them

pip3 uninstall PyQt5 PyQt5-Qt5 PyQt5-sip PyQtWebEngine PyQtWebEngine-Qt5

And later I installed QtWebEngine using apt
(apt automatically installed also PyQt5 and I didn't need to use pip for this)

apt install python3-pyqt5.qtwebengine

It installed also other C/C++ libraries - and maybe this was needed to work corrrectly.

The following additional packages will be installed:
  libqt5designer5 libqt5qml5 libqt5qmlmodels5 libqt5quick5 libqt5quickwidgets5 libqt5test5 libqt5webchannel5
  libqt5webengine-data libqt5webengine5 libqt5webenginecore5 libqt5webenginewidgets5 libre2-9 python3-pyqt5
  python3-pyqt5.qtwebchannel python3-pyqt5.sip

And now pip3 freeze shows me:

PyQt5==5.15.6
PyQt5-sip==12.9.1
PyQtWebEngine==5.15.5

And now your code works for me.


Similar questions:

python - Unable to render webpage using QWebEngineView - Stack Overflow

python 3.x - PyQt5 QWebEngineView does not show webpage - Stack Overflow

python - Displaying web page with PyQt5 WebEngine - Stack Overflow

furas
  • 134,197
  • 12
  • 106
  • 148