Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FigureWidget fails with anywidget in v6.0.0 #5027

Open
turbotimon opened this issue Feb 11, 2025 · 5 comments
Open

FigureWidget fails with anywidget in v6.0.0 #5027

turbotimon opened this issue Feb 11, 2025 · 5 comments
Assignees
Labels
bug something broken P1 needed for current cycle

Comments

@turbotimon
Copy link

turbotimon commented Feb 11, 2025

Problem:
Since v6.0.0 FigureWidget uses anywidget. However, it fails with a java script error.

$ pip show plotly anywidget
Name: plotly
Version: 6.0.0
Summary: An open-source, interactive data visualization library for Python
Home-page: https://plotly.com/python/
Author: Chris P
Author-email: [email protected]
License: MIT
Location: /home/erti/PROJECT_repos/ForeST_HPO/hpo-innosuisse/.venv_anywidget/lib/python3.11/site-packages
Requires: narwhals, packaging
Required-by: 
---
Name: anywidget
Version: 0.9.13
Summary: custom jupyter widgets made easy
Home-page: 
Author: 
Author-email: Trevor Manz <[email protected]>
License: MIT
Location: /home/erti/PROJECT_repos/ForeST_HPO/hpo-innosuisse/.venv_anywidget/lib/python3.11/site-packages
Requires: ipywidgets, psygnal, typing-extensions
Required-by: 
import plotly.graph_objs as go
fig = go.FigureWidget()
fig.add_scatter(y=[2, 1, 4, 3])
fig

Either, no output (no figure) is shown or this is shown:

Failed to load view class 'AnyView' from module 'anywidget'
Error: No version of module anywidget is registered
    at WidgetManager.loadClass (https://file+.vscode-resource.vscode-cdn.net/home/erti/.vscode/extensions/ms-toolsai.jupyter-renderers-1.1.0/out/node_modules/%40vscode/jupyter-ipywidgets8/dist/ipywidgets.js:2:2420023)
    at WidgetManager.loadClass (https://file+.vscode-resource.vscode-cdn.net/home/erti/.vscode/extensions/ms-toolsai.jupyter-renderers-1.1.0/out/node_modules/%40vscode/jupyter-ipywidgets8/dist/ipywidgets.js:2:2803837)
    at WidgetManager.loadViewClass (https://file+.vscode-resource.vscode-cdn.net/home/erti/.vscode/extensions/ms-toolsai.jupyter-renderers-1.1.0/out/node_modules/%40vscode/jupyter-ipywidgets8/dist/ipywidgets.js:2:2417001)
    at https://file+.vscode-resource.vscode-cdn.net/home/erti/.vscode/extensions/ms-toolsai.jupyter-renderers-1.1.0/out/node_modules/%40vscode/jupyter-ipywidgets8/dist/ipywidgets.js:2:2410155
    at async Tt.renderWidget (https://file+.vscode-resource.vscode-cdn.net/home/erti/.vscode/extensions/ms-toolsai.jupyter-2024.11.0-linux-x64/dist/webviews/webview-side/ipywidgetsKernel/ipywidgetsKernel.js:17:17328)
    at async op (https://file+.vscode-resource.vscode-cdn.net/home/erti/.vscode/extensions/ms-toolsai.jupyter-2024.11.0-linux-x64/dist/webviews/webview-side/ipywidgetsKernel/ipywidgetsKernel.js:17:31113)

Workaround:
Downgrading to plotly-5.24 solves the problem

Related:
Maybe somewhat related to #4996

@turbotimon turbotimon changed the title FigureWidget fails with anywidget in v6.0.0 [BUG] FigureWidget fails with anywidget in v6.0.0 Feb 11, 2025
@gvwilson gvwilson added bug something broken P1 needed for current cycle labels Feb 11, 2025
@gvwilson gvwilson changed the title [BUG] FigureWidget fails with anywidget in v6.0.0 FigureWidget fails with anywidget in v6.0.0 Feb 11, 2025
@marthacryan
Copy link
Collaborator

Could you describe the way that you installed anywidget? I was seeing this issue when I installed anywidget while JupyterLab was running without restarting it. I'm curious if restarting JupyterLab / reloading the page would help. (Still a bug, just good info for debugging)

@turbotimon
Copy link
Author

turbotimon commented Feb 12, 2025

@marthacryan I created a fresh venv with python3.11 and run pip install plotly anywidget and run the code in vscode notebook. I also restarted the kernel several times, somties just no output is shown, somtimes the json error. I also tried to run it in google colab. There, I don't see the json error, but also get no output (the figure is not shown).

@marthacryan
Copy link
Collaborator

Thank you for the info @turbotimon! Looks like this is an issue with plotly.js==3.0.0, which we updated to for the plotly.py==6.0.0 release. I'll investigate why this is happening but as a note, I think it may be related to removing require.js and needing to update the way that we include plotly.js.

@marthacryan
Copy link
Collaborator

Update here: looks like there is a PR open that does fix this issue for plotly.js: plotly/plotly.js#7367.

@marthacryan
Copy link
Collaborator

Plotly.js just released the 3.0.1 patch which will fix this! We'll need to update the plotly.js version in plotly.py, so I'll wait on that to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P1 needed for current cycle
Projects
None yet
Development

No branches or pull requests

3 participants