"Requested OpenGL implementation is not supported. Implementation: 1" pyqt5 错误

"Requested OpenGL implementation is not supported. Implementation: 1" error in pyqt5

当我运行这个代码

from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import *

import sys

class MainWindow(QMainWindow):

    def __init__(self, *args, **kwargs):
        super(MainWindow,self).__init__(*args, **kwargs)

        self.browser = QWebEngineView()
        self.browser.setUrl(QUrl("http://www.google.com"))

        self.setCentralWidget(self.browser)

        self.show()

app = QApplication(sys.argv)
window = MainWindow()

app.exec_()

我收到这个错误

[6448:3156:0715/200747.900:ERROR:gl_surface_wgl.cc(399)] Unable to create pbuffer.
[6448:3156:0715/200747.900:ERROR:gl_surface_qt.cpp(197)] Requested OpenGL implementation is not supported. Implementation: 1

这个错误的原因和解决方法是什么?

或者是否有 QtWebEngineWidgets 的替代品?

日志指出 opengl 存在问题,因此您可以更改设置:

# ...
QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL)
# or
# QCoreApplication.setAttribute(Qt.AA_UseOpenGLES)

app = QApplication(sys.argv)
# ...

有关详细信息,请参阅 Graphics Drivers