{"id":7601,"library":"pyqtwebengine-qt5","title":"PyQtWebEngine (Qt5)","description":"PyQtWebEngine (Qt5) provides the Python bindings for Qt WebEngine, allowing the embedding of web content (based on Chromium) directly into PyQt5 applications. This package specifically targets applications built with PyQt5. It is maintained by Riverbank Computing and typically releases new versions in sync with PyQt5 and Qt5 patch releases.","status":"active","version":"5.15.18","language":"en","source_language":"en","source_url":"https://www.riverbankcomputing.com/software/pyqtwebengine/","tags":["GUI","Qt","WebEngine","browser","webview"],"install":[{"cmd":"pip install pyqtwebengine-qt5","lang":"bash","label":"Install core package"},{"cmd":"pip install pyqt5 pyqtwebengine-qt5","lang":"bash","label":"Install with PyQt5 (if not already present)"}],"dependencies":[{"reason":"Provides the core Qt5 bindings that PyQtWebEngine integrates with. pyqtwebengine-qt5 requires PyQt5.","package":"PyQt5"}],"imports":[{"symbol":"QApplication","correct":"from PyQt5.QtWidgets import QApplication"},{"note":"PyQtWebEngine classes are integrated into the PyQt5 namespace, not a separate top-level 'pyqtwebengine' module.","wrong":"from pyqtwebengine import QWebEngineView","symbol":"QWebEngineView","correct":"from PyQt5.QtWebEngineWidgets import QWebEngineView"},{"symbol":"QUrl","correct":"from PyQt5.QtCore import QUrl"}],"quickstart":{"code":"import sys\nfrom PyQt5.QtWidgets import QApplication\nfrom PyQt5.QtWebEngineWidgets import QWebEngineView\nfrom PyQt5.QtCore import QUrl\n\ndef main():\n    app = QApplication(sys.argv)\n\n    browser = QWebEngineView()\n    browser.setUrl(QUrl('https://www.google.com')) # For PyQtWebEngine 5.15.x, setUrl is still commonly used.\n    browser.show()\n\n    sys.exit(app.exec_())\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates how to create a simple web browser view within a PyQt5 application, displaying Google's homepage."},"warnings":[{"fix":"Ensure `pip install pyqt5` has been run before or alongside `pip install pyqtwebengine-qt5`.","message":"Installing `pyqtwebengine-qt5` does not automatically install `PyQt5`. You must install `PyQt5` separately if it's not already part of your environment.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always initialize `QApplication(sys.argv)` and call `sys.exit(app.exec_())` in your main application entry point.","message":"All PyQt applications, including those using PyQtWebEngine, require a `QApplication` instance to be created and an event loop to be run (`app.exec_()`) for the GUI to display and interact correctly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Replace `browser.setUrl(QUrl('...'))` with `browser.load(QUrl('...'))` for forward compatibility, though `setUrl` remains functional in 5.15.","message":"The `QWebEngineView.setUrl()` method is technically deprecated in newer Qt versions (and by extension, PyQt) in favor of `QWebEngineView.load(QUrl)`. While it still works in PyQt5, it's good practice to use `load()`.","severity":"deprecated","affected_versions":"Qt 5.15+, PyQtWebEngine 5.15+"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install pyqtwebengine-qt5` to ensure the package is installed correctly.","cause":"The `pyqtwebengine-qt5` package is not installed, or the PyQt5 installation is corrupted/incomplete.","error":"ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'"},{"fix":"Ensure `app = QApplication(sys.argv)` is called before creating any widgets, and `app.exec_()` is called to start the event loop.","cause":"The `QApplication` instance has not been created or the event loop has not started, preventing GUI elements from being properly initialized or displayed.","error":"AttributeError: 'PyQt5.QtWebEngineWidgets.QWebEngineView' object has no attribute 'show'"},{"fix":"Try reinstalling both `pyqt5` and `pyqtwebengine-qt5` (`pip uninstall pyqtwebengine-qt5 pyqt5 && pip install pyqt5 pyqtwebengine-qt5`). Check for PATH conflicts with other Qt installations. In some cases, updating graphics drivers or ensuring system dependencies are met might help.","cause":"This usually indicates an issue with the underlying Qt5 installation (often with PyQt5 itself) or conflicting Qt environments/DLLs on Windows, preventing the QtWebEngine part from loading.","error":"ImportError: DLL load failed while importing QtWebEngineWidgets: The specified module could not be found."}]}