plotly / plotly/plotly.py

`FigureWidget` fails with `anywidget` in colab

未关闭
#5,027 11 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P2
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

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: chris@plot.ly
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 <trevor.j.manz@gmail.com>
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 https://github.com/plotly/plotly.py/issues/4996

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用提供的 FigureWidget 代码片段,通过 Plotly 6.0.0 和 anywidget 0.9.13 重现该问题,然后与 plotly-5.24 进行比较。首先跟踪 FigureWidget 和 anywidget 的集成;当图形在受影响的 notebook 环境中渲染且不再出现报告的 JavaScript 错误时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
jupyter-notebook, python
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。