QWebEngineView not showing on Linux Mint
Solved
QtWebEngine
-
Hello,
I have an issue on my Linux Mint installation with the PyQt Web View, as it doesn't show anything, just some white. It perfectly works on Windows11, but not on Linux.
Here is the entire code:import PyQt5.QtWidgets as Qt from PyQt5 import QtCore import PyQt5.QtWebEngineWidgets as QtWeb class WebView(Qt.QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("Web View") self.setGeometry(100, 100, 800, 600) self.webview = QtWeb.QWebEngineView(self) self.setCentralWidget(self.webview) self.webview.load(QtCore.QUrl("https://www.google.com")) if __name__ == "__main__": app = Qt.QApplication([]) window = WebView() window.show() app.exec_()
And here is the result:
I'm using Linux Mint version 21.3, PyQt5 version 5.15.10 and PyQtWebEngine version 5.15.6
Here are all the system information:
Hope someone can help me, thanks. -
Found the problem, I'm replying if someone else got the same problem.
I needed to put this line of code :os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--no-sandbox"
And to use
sys.argv
when initializing the app :App = Qt.QApplication(sys.argv)
The final code being the following :
import PyQt5.QtWidgets as Qt from PyQt5 import QtCore import PyQt5.QtWebEngineWidgets as QtWeb import sys import os class WebView(Qt.QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("Web View") self.setGeometry(100, 100, 800, 600) self.webview = QtWeb.QWebEngineView(self) self.setCentralWidget(self.webview) self.webview.load(QtCore.QUrl("https://www.google.com")) if __name__ == "__main__": os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--no-sandbox" App = Qt.QApplication(sys.argv) window = WebView() window.show() app.exec_()
Hope it helps if someone gets the same issue !
-