Plotly.py: FigureWidget does not work with Jupyter lab 1.2.5

Created on 14 Apr 2020  路  12Comments  路  Source: plotly/plotly.py

Installed following https://github.com/plotly/plotly.py/blob/master/README.md#jupyterlab-support-python-35

Jupyter lab 1.2.5

extensions

@8080labs/qgrid v1.1.1  enabled  OK
@bokeh/jupyter_bokeh v1.2.0  enabled  OK
@jupyter-widgets/jupyterlab-manager v1.1  enabled  OK
@jupyterlab/toc v2.0.0  enabled  OK
@pyviz/jupyterlab_pyviz v0.8.0  enabled  OK
ipysheet v0.4.3  enabled  OK
jupyter-matplotlib v0.7.2  enabled  OK
jupyter-widget-datetime v1.0.0  enabled  OK
jupyterlab-plotly v4.6.0  enabled  OK

pip

matplotlib==3.1.3
plotly==4.6.0
ipywidgets==7.5.1

Results in

image

Most helpful comment

Sorry, my bad @srottschaefer

This is the current state, and it shows the same error on JupyterHub (locall JupyterLab works)

Thanks

JupyterLab v1.2.5
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @8080labs/qgrid v1.1.1  enabled  OK
        @bokeh/jupyter_bokeh v1.2.0  enabled  OK
        @jupyter-widgets/jupyterlab-manager v1.1.0  enabled  OK
        @jupyterlab/toc v2.0.0  enabled  OK
        @pyviz/jupyterlab_pyviz v0.8.0  enabled  OK
        ipysheet v0.4.3  enabled  OK
        jupyter-matplotlib v0.7.2  enabled  OK
        jupyter-widget-datetime v1.0.0  enabled  OK
        jupyterlab-plotly v4.6.0  enabled  OK
        plotlywidget v4.6.0  enabled  OK
plotly==4.6.0
ipywidgets==7.5.1
jupyterlab==1.2.5
jupyterlab-server==1.0.7

All 12 comments

Yes, to use the FigureWidget you need to have the plotlywidget extension installed as well: https://plotly.com/python/getting-started/

Installing plotlywidget doesn't seem to help (JLab v1.2.6 though):

import plotly.graph_objects as go
go.FigureWidget()

Error displaying widget: model not found

JS console shows several errors:

Could not instantiate widget                              manager-base.js:273
Error: "Could not create a model."                        utils.js:119
Exception opening new comm                                default.js:1001
Error: "Module plotlywidget, semver range 4.6.0           default.js:127
    is not registered as a widget module"

jupyter labextension list

@jupyter-widgets/jupyterlab-manager v1.1.0  enabled  OK
        jupyterlab-plotly v4.6.0  enabled  OK
        plotlywidget v4.6.0  enabled  OK

conda list

...
ipywidgets                7.5.1                      py_0
...
jupyterlab                1.2.6              pyhf63ae98_0
...
plotly                    4.6.0                      py_0    plotly
...
import plotly.graph_objects as go
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
fig.show()

works as expected

and FigureWidget also works in Jupyter Notebook.
I completely wiped the conda environment and setup a new one with the same result

Forget what I wrote above. For an unknown reason it started working. I reverted back to my old environment and it suddenly asked me to rebuild the extensions in the JLab frontend (although I already did so on the CLI). After rebuilding it started working o.O

Sorry, my bad @srottschaefer

This is the current state, and it shows the same error on JupyterHub (locall JupyterLab works)

Thanks

JupyterLab v1.2.5
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @8080labs/qgrid v1.1.1  enabled  OK
        @bokeh/jupyter_bokeh v1.2.0  enabled  OK
        @jupyter-widgets/jupyterlab-manager v1.1.0  enabled  OK
        @jupyterlab/toc v2.0.0  enabled  OK
        @pyviz/jupyterlab_pyviz v0.8.0  enabled  OK
        ipysheet v0.4.3  enabled  OK
        jupyter-matplotlib v0.7.2  enabled  OK
        jupyter-widget-datetime v1.0.0  enabled  OK
        jupyterlab-plotly v4.6.0  enabled  OK
        plotlywidget v4.6.0  enabled  OK
plotly==4.6.0
ipywidgets==7.5.1
jupyterlab==1.2.5
jupyterlab-server==1.0.7

Also having this issue with JupyterLab 2.1.4 (Python 3.8.2)

JupyterLab v2.1.4 
Known labextensions:
   app dir: /Users/nicokreiling/.local/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        jupyterlab-chart-editor v4.7.1  enabled  OK
        jupyterlab-plotly v4.8.1  enabled  OK
ipywidgets==7.5.1
plotly==4.8.1

+1, Also have this issue.

python version: 3.7.2

pip:

jupyterlab                1.2.6
jupyterlab-server         1.0.6
plotly                    4.8.1

labextensions:

@jupyter-widgets/jupyterlab-manager v1.1.0  enabled  OK
jupyter-matplotlib v0.7.2  enabled  OK
jupyterlab-plotly v4.8.1  enabled  OK
jupyterlab_vim v0.11.0  enabled  OK
plotlywidget v4.8.1  enabled  OK
qgrid2 v1.1.3  enabled  OK*

Same here with JupyterLab 2.1.4 and plotly 4.8.2

JupyterLab v2.1.4
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @bokeh/jupyter_bokeh v2.0.2  enabled  OK
        @jupyter-voila/jupyterlab-preview v1.1.0  enabled  OK
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        @jupyterlab/git v0.20.0  enabled  OK
        @jupyterlab/toc v4.0.0  enabled  OK
        @krassowski/jupyterlab_go_to_definition v1.0.0  enabled  OK
        @ryantam626/jupyterlab_code_formatter v1.3.1  enabled  OK
        bqplot v0.5.13  enabled  OK
        dask-labextension v2.0.2  enabled  OK
        jupyter-leaflet v0.13.1  enabled  OK
        jupyter-matplotlib v0.7.2  enabled  OK
        jupyter-threejs v2.2.0  enabled  OK
        jupyter-webrtc v0.5.0  enabled  OK
        jupyterlab-datawidgets v6.2.0  enabled  OK
        jupyterlab-drawio v0.7.0  enabled  OK
        jupyterlab-jupytext v1.2.1  enabled  OK
        jupyterlab-plotly v4.8.2  enabled  OK
        nbdime-jupyterlab v2.0.0  enabled  OK
        plotlywidget v4.8.2  enabled  OK

In the dev console it shows:

Error: Module plotlywidget, semver range ^4.8.2 is not registered as a widget module

Any ideas on how to debug/fix this?

I'm having trouble pinning down the source of this issue, so it would be really helpful if folks could, in addition to posting their versions (which is great!) post the error message they're seeing in the notebook itself, and any errors in the Javascript console please.

@nicolaskruchten IMHO this is actually a problem of ipywidgets: https://github.com/jupyter-widgets/ipywidgets/issues/2899

At least I was able to get around the problem by manually installing the previous ipywidgets version (widgetsnbextension=3.4.2 instead of widgetsnbextension=3.5), a binder example can also be seen here: https://github.com/krlng/2020_m3_online

Interesting, thanks @krlng for that info! I wonder if this bug isn't triggered by something else, though, because many folks are able to get things running with ipywidgets 7.5 and JupyterLab 1.x as well as 2.x, so we need to identify the common thread here...

So after many iterations of experimentation, I've concluded that often, just running jupyter lab build will clear up this issue. I don't know what causes it, but any time I've replicated it, rebuilding has fixed it, although note that you'll need to clear and rerun your notebook to confirm: simply re-opening JupyterLab will show the previous error until the cell is rerun.

This is pretty unsatisfying but it's the best I've got at the moment.

Was this page helpful?
0 / 5 - 0 ratings