Skip to content

js: uncaught ReferenceError #4255

@s-weissbach

Description

@s-weissbach

Hello,
When attempting to plot something within PyQt6 using Plotly on Windows, an error is encountered: "js: uncaught ReferenceError: Plotly is not defined." This issue prevents the successful execution of Plotly-based visualizations within a PyQt6 application, hindering the intended functionality.

Installed versions:

  • plotly (5.9.0)
  • pyqt6 (6.5.0)
  • pyqt6-webengine (6.5.0)

Script to Reproduce:

import sys
import plotly.express as px
from PyQt6 import QtWebEngineWidgets
from PyQt6.QtWidgets import QApplication, QVBoxLayout, QWidget, QVBoxLayout


class minimal_example(QWidget):
    def __init__(self):
        super().__init__()
        self.directory = None
        # layout
        self.mainwindowlayout = QVBoxLayout()
        min_plot = QtWebEngineWidgets.QWebEngineView(self)
        x = [1,2,3,4,5]
        y = [5,4,3,2,1]
        fig = px.line(x=x, y=y)
        min_plot.setHtml(
            fig.to_html(include_plotlyjs="cdn")   
        )
        self.mainwindowlayout.addWidget(min_plot)
        self.setLayout(self.mainwindowlayout)

def main():
    app = QApplication(sys.argv)
    main = minimal_example()
    main.show()
    sys.exit(app.exec())


if __name__ == "__main__":
    main()

When running this, it will return:
js: uncaught ReferenceError: Plotly is not defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions