在 RasPi 4B 上导入 QWebEnginePage 时 QApplication 中断

QApplication breaks when importing QWebEnginePage on RasPi 4B

我的代码:

from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEnginePage

print("this code is reached")
app = QApplication(["foo"])
print("this code is not reached")

导致错误:

this code is reached
qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
Could not initialize GLX

但是,如果我不导入 QWebEnginePage(只是取消注释第 3 行),代码就可以工作。

我的系统:Ubuntu 20.04,RaspberryPi 4B

根据 我会看看推荐的答案是否解决了您的问题

sudo apt-get install libgl1-mesa-dri

export QT_XCB_GL_INTEGRATION=none 解决问题。但是我想知道是否可以在不禁用 OpenGL 的情况下解决它。来自 Teejay Bruno 提到的 的答案。