我正在尝试将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)
我能做什么
我试图按照@tromgy的建议安装windows media功能包,但显然“这些更改不适用于”我的电脑,所以我从https://www.dll-files.com/一个接一个地下载了dll-s,并将它们粘贴到C:\windows\System32,现在代码正常了
相关问题 更多 >
编程相关推荐