question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatible FigureWidget with ipywidgets 8.0.0rc0

See original GitHub issue

Plotly’s FigureWidget does not appear to be compatible with the upcoming ipywidgets release.

python -m venv .venv
. ./.venv/bin/activate
pip install plotly jupyterlab ipywidgets==8.0.0rc0
jupyer-lab

If using directly the FigureWidget as the output of the cell, the figure is shown by with the following error:

import plotly.graph_objects as go

go.FigureWidget(go.Scatter(x=[1, 2, 3], y=[1, 4, 9]))
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /tmp/josh/bug-report/.venv/lib/python3.10/site-packages/IPython/core/formatters.py:921, in IPythonDisplayFormatter.__call__(self, obj)
    919 method = get_real_method(obj, self.print_method)
    920 if method is not None:
--> 921     method()
    922     return True

File /tmp/josh/bug-report/.venv/lib/python3.10/site-packages/plotly/basewidget.py:741, in BaseFigureWidget._ipython_display_(self)
    737 """
    738 Handle rich display of figures in ipython contexts
    739 """
    740 # Override BaseFigure's display to make sure we display the widget version
--> 741 widgets.DOMWidget._ipython_display_(self)

AttributeError: type object 'DOMWidget' has no attribute '_ipython_display_'

On the other hand, if the FigureWidget is used within other widgets, the figure does not appear at all (though there isn’t any error message):

import plotly.graph_objects as go
from ipywidgets import widgets

widgets.VBox([
    widgets.HTML("<p>Start</p>"),
    go.FigureWidget(go.Scatter(x=[1, 2, 3], y=[1, 4, 9])),
    widgets.HTML("<p>End</p>"),
])

image

This was generated using Plotly 5.7.0 and ipywidgets 8.0.0rc0 all within JupyterLab 3.3.4.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:12
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
fabratucommented, Aug 19, 2022

The same error occurs for plotly 5.8.0 and 5.9.0.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File ~/miniforge3/envs/nwk10/lib/python3.10/site-packages/IPython/core/formatters.py:921, in IPythonDisplayFormatter.__call__(self, obj)
    919 method = get_real_method(obj, self.print_method)
    920 if method is not None:
--> 921     method()
    922     return True

File ~/miniforge3/envs/nwk10/lib/python3.10/site-packages/plotly/basewidget.py:741, in BaseFigureWidget._ipython_display_(self)
    737 """
    738 Handle rich display of figures in ipython contexts
    739 """
    740 # Override BaseFigure's display to make sure we display the widget version
--> 741 widgets.DOMWidget._ipython_display_(self)

AttributeError: type object 'DOMWidget' has no attribute '_ipython_display_'

Together with jupyterlab, it is also not so clear how to resolve it. Installing ipywidgets<8.X is not automatically registered with jupyterlab 3.4.X (leading to a blank output).

Error: Module @jupyter-widgets/base, version ^1.2.0 is not registered, however,         2.0.0 is
    loadClass http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.c8db098d38011369cafa.js?v=c8db098d38011369cafa:1
    loadModelClass http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.a4d4bb4ed1bc1a3626c7.js?v=a4d4bb4ed1bc1a3626c7:1
    _make_model http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.a4d4bb4ed1bc1a3626c7.js?v=a4d4bb4ed1bc1a3626c7:1
    new_model http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.a4d4bb4ed1bc1a3626c7.js?v=a4d4bb4ed1bc1a3626c7:1
    handle_comm_open http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.a4d4bb4ed1bc1a3626c7.js?v=a4d4bb4ed1bc1a3626c7:1
    _handleCommOpen http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.c8db098d38011369cafa.js?v=c8db098d38011369cafa:1
    _handleCommOpen http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2

Update: Solved at least jupyterlab + prev. ipywidgets versions by installing package jupyterlab-widgets in version 1.1.1:

pip install ipywidgets==7.7.1 jupyterlab-widgets==1.1.1
1reaction
darynwhitecommented, Aug 23, 2022

This is come into production and is causing a problem with a live environment, but I have found this reference as a fix: https://github.com/jupyter-widgets/ipywidgets/issues/3552#issuecomment-1220997361

Read more comments on GitHub >

github_iconTop Results From Across the Web

install ipywidgets - Read the Docs
No information is available for this page.
Read more >
Ipywidgets 8.0.0rc0 prerelease - please test - Widgets
We've released ipywidgets 8.0rc0. Please test and file an issue at GitHub - jupyter-widgets/ipywidgets: Interactive Widgets for the Jupyter ...
Read more >
Interactive data analysis with figurewidget ipywidgets in Python
Let's assign the widgets that we're going to be using in our app. In general all these widgets will be used to filter...
Read more >
How to get ipywidgets working in Jupyter Lab? - Stack Overflow
Simply install the python ipywidgets package with pip (pip install ipywidgets==7.6.0) or conda/mamba (conda install -c conda-forge ipywidgets= ...
Read more >
ipywidgets · PyPI
This package contains the python implementation of the core interactive widgets bundled in ipywidgets. Core Interactive Widgets. The fundamental widgets ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found