与pyqt5一起使用plotly

2024-10-01 02:38:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将plotly与pyqt5一起使用。我在这里找到了一个示例代码:How to have plotly graph as PyQt5 widget? 代码如下:

from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets
import plotly.express as px


class Widget(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.button = QtWidgets.QPushButton('Plot', self)
        self.browser = QtWebEngineWidgets.QWebEngineView(self)

        vlayout = QtWidgets.QVBoxLayout(self)
        vlayout.addWidget(self.button, alignment=QtCore.Qt.AlignHCenter)
        vlayout.addWidget(self.browser)

        self.button.clicked.connect(self.show_graph)
        self.resize(1000,800)

    def show_graph(self):
        df = px.data.tips()
        fig = px.box(df, x="day", y="total_bill", color="smoker")
        fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
        self.browser.setHtml(fig.to_html(include_plotlyjs='cdn'))

if __name__ == "__main__":
    app = QtWidgets.QApplication([])
    widget = Widget()
    widget.show()
    app.exec()

当我尝试运行它时,我得到以下错误消息:

[18152:16788:0924/110112.767:ERROR:dxva_video_decode_accelerator_win.cc(1399)] DXVAVDA fatal error: could not LoadLibrary: mf.dll: The specified module could not be found. (0x7E)
[18152:16788:0924/110112.770:ERROR:dxva_video_decode_accelerator_win.cc(1399)] DXVAVDA fatal error: could not LoadLibrary: mfplat.dll: The specified module could not be found. (0x7E)
[18152:16788:0924/110112.771:ERROR:dxva_video_decode_accelerator_win.cc(1399)] DXVAVDA fatal error: could not LoadLibrary: msmpeg2vdec.dll: The specified module could not be found. (0x7E)
[18152:16788:0924/110112.773:ERROR:dxva_video_decode_accelerator_win.cc(1407)] DXVAVDA fatal error: could not LoadLibrary: msvproc.dll: The specified module could not be found. (0x7E)

我能做什么


Tags: selfvideonoterrorwincouldccdecode