matplotlib / ipympl

Matplotlib Jupyter Integration
https://matplotlib.org/ipympl/
BSD 3-Clause "New" or "Revised" License
1.59k stars 225 forks source link

Error displaying widget: model not found #511

Closed rcpeene closed 1 year ago

rcpeene commented 1 year ago

Describe the issue

I am running a Jupyter notebook within Binder. In the notebook I attempt to use ccf-widgets, (which is in-turn dependent on itkwidgets) to render a 3D model. This works in Jupyter on my local machine, but on binder it fails to render and yields Error displaying widget: model not found I mentioned this on issue #456, but I figured it was better to issue my problem separately. As mentioned there, uninstalling ipywebrtc doesn't seem to fix it. The workarounds discussed on issue #473 aren't applicable here, as I don't have control of the JupyterLab version used on Binder.

Versions

The Jupyterlab version running on binder is 3.4.8. I'm using ipympl==0.9.2 and matplotlib==3.6.2

Output of the provided command:

python -c "import sys; print('\n',sys.version); import ipympl; print('ipympl version:', ipympl.__version__)" && jupyter --version && jupyter nbextension list && jupyter labextension list

-->


 3.8.15 | packaged by conda-forge | (default, Nov 22 2022, 08:49:35) 
[GCC 10.4.0]
ipympl version: 0.9.2
Selected Jupyter core packages...
IPython          : 8.7.0
ipykernel        : 6.17.1
ipywidgets       : 7.7.2
jupyter_client   : 7.4.7
jupyter_core     : 5.1.0
jupyter_server   : 1.23.3
jupyterlab       : 3.4.8
nbclient         : 0.7.2
nbconvert        : 7.2.5
nbformat         : 5.7.0
notebook         : 6.5.2
qtconsole        : 5.4.0
traitlets        : 5.6.0
Known nbextensions:
  config dir: /srv/conda/envs/notebook/etc/jupyter/nbconfig
    notebook section
      bqplot/extension  enabled 
      - Validating: OK
      ipydatagrid/extension  enabled 
      - Validating: OK
      ipytree/extension  enabled 
      - Validating: OK
      ipyvolume/extension  enabled 
      - Validating: OK
      itkwidgets/extension  enabled 
      - Validating: OK
      jupyter-datawidgets/extension  enabled 
      - Validating: OK
      jupyter-matplotlib/extension  enabled 
      - Validating: OK
      jupyter-threejs/extension  enabled 
      - Validating: OK
      jupyter-vue/extension  enabled 
      - Validating: OK
      jupyter-vuetify/extension  enabled 
      - Validating: OK
      jupyter-webrtc/extension  enabled 
      - Validating: OK
      jupyter_resource_usage/main  enabled 
      - Validating: OK
      jupyterlab-plotly/extension  enabled 
      - Validating: OK
      jupyter-offlinenotebook/main  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
JupyterLab v3.4.8
/srv/conda/envs/notebook/share/jupyter/labextensions
        jupyter-offlinenotebook v0.2.2 enabled OK
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        jupyter-webrtc v0.6.0 enabled OK
        jupyterlab-datawidgets v7.1.2 enabled OK
        jupyter-threejs v2.4.0 enabled OK (python, pythreejs)
        ipydatagrid v1.1.14 enabled OK
        jupyter-matplotlib v0.11.2 enabled OK
        jupyter-vuetify v1.8.4 enabled OK
        ipyvolume v0.6.0-alpha.10 enabled OK
        jupyterlab-plotly v5.11.0 enabled OK
        bqplot v0.5.37 enabled OK (python, bqplot)
        jupyter-vue v1.8.0 enabled OK
        ipytree v0.2.2 enabled OK
        @jupyter-widgets/jupyterlab-manager v3.1.1 enabled OK (python, jupyterlab_widgets)
        @jupyter-server/resource-usage v0.7.0 enabled  X (python, jupyter-resource-usage)

"@jupyter-server/resource-usage@0.7.0" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab              Extension      Package
>=3.4.8 <3.5.0          >=3.5.1 <4.0.0 @jupyterlab/application
>=3.4.8 <3.5.0          >=3.5.1 <4.0.0 @jupyterlab/apputils
>=5.4.8 <5.5.0          >=5.5.1 <6.0.0 @jupyterlab/coreutils
>=3.4.8 <3.5.0          >=3.5.1 <4.0.0 @jupyterlab/notebook
>=6.4.8 <6.5.0          >=6.5.1 <7.0.0 @jupyterlab/services
>=3.4.8 <3.5.0          >=3.5.1 <4.0.0 @jupyterlab/statusbar
>=3.4.8 <3.5.0          >=3.5.1 <4.0.0 @jupyterlab/translation

Other labextensions (built into JupyterLab)
   app dir: /srv/conda/envs/notebook/share/jupyter/lab```
rcpeene commented 1 year ago

Here's the pip freeze of the environment setup on binder.

aiohttp==3.8.3
aiosignal==1.3.1
alembic @ file:///home/conda/feedstock_root/build_artifacts/alembic_1671877868880/work
anyio @ file:///home/conda/feedstock_root/build_artifacts/anyio_1666191106763/work/dist
appdirs==1.4.4
argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1640817743617/work
argon2-cffi-bindings @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi-bindings_1666850853622/work
arrow==1.2.3
asciitree==0.3.3
asttokens==2.2.0
async-generator==1.10
async-timeout==4.0.2
attrs==22.1.0
Babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1667688356751/work
backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work
backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1618230623929/work
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1649463573192/work
bidsschematools==0.6.0
bleach @ file:///home/conda/feedstock_root/build_artifacts/bleach_1656355450470/work
blessings==1.7
blinker @ file:///home/conda/feedstock_root/build_artifacts/blinker_1664823096650/work
bqplot==0.12.36
brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1666764652625/work
ccfwidget==0.5.3
certifi==2022.9.24
certipy==0.1.3
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1671179356964/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1661170624537/work
ci-info==0.3.0
click==8.1.3
click-didyoumean==0.3.0
cloudpickle==2.2.0
colorama==0.4.6
colorcet==3.0.1
comm @ file:///home/conda/feedstock_root/build_artifacts/comm_1670575068857/work
contourpy==1.0.6
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography-split_1672672382550/work
cycler==0.11.0
dandi==0.46.6
dandischema==0.7.1
dask==2022.11.1
debugpy==1.6.4
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1641555617451/work
defusedxml @ file:///home/conda/feedstock_root/build_artifacts/defusedxml_1615232257335/work
dnspython==2.2.1
email-validator==1.3.0
entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work
etelemetry==0.3.0
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1667317341051/work
fasteners==0.18
fastjsonschema @ file:///home/conda/feedstock_root/build_artifacts/python-fastjsonschema_1663619548554/work/dist
flit_core @ file:///home/conda/feedstock_root/build_artifacts/flit-core_1667734568827/work/source/flit_core
fonttools==4.38.0
fqdn==1.5.1
frozenlist==1.3.3
fscacher==0.2.0
fsspec==2022.11.0
gast==0.4.0
greenlet @ file:///home/conda/feedstock_root/build_artifacts/greenlet_1667836512058/work
h5py==3.7.0
hdmf==3.4.7
humanize==4.4.0
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1663625384323/work
imageio==2.22.4
importlib-metadata==4.13.0
importlib-resources==5.10.0
interleave==0.2.1
ipydatagrid==1.1.14
ipydatawidgets==4.3.2
ipykernel==6.17.1
ipympl==0.9.2
ipython==8.7.0
ipython-genutils==0.2.0
ipytree==0.2.2
ipyvolume==0.6.0a10
ipyvue==1.8.0
ipyvuetify==1.8.4
ipywebrtc==0.6.0
ipywidgets==7.7.2
isoduration==20.11.0
itk-core==5.3.0
itk-filtering==5.3.0
itk-meshtopolydata==0.10.0
itk-numerics==5.3.0
itkwidgets==0.32.4
jaraco.classes==3.2.3
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1669134318875/work
jeepney==0.8.0
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1654302431367/work
joblib==1.2.0
json5 @ file:///home/conda/feedstock_root/build_artifacts/json5_1600692310011/work
jsonpointer==2.3
jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema-meta_1669810440410/work
jupyter==1.0.0
jupyter-console==6.4.4
jupyter-offlinenotebook @ file:///home/conda/feedstock_root/build_artifacts/jupyter-offlinenotebook_1643188995077/work
jupyter-resource-usage @ file:///home/conda/feedstock_root/build_artifacts/jupyter-resource-usage_1673012018482/work
jupyter-server==1.23.3
jupyter-telemetry @ file:///home/conda/feedstock_root/build_artifacts/jupyter_telemetry_1605173804246/work
jupyter_client==7.4.7
jupyter_core==5.1.0
jupyterhub @ file:///home/conda/feedstock_root/build_artifacts/jupyterhub-feedstock_1637050536914/work
jupyterlab @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_1664896434903/work
jupyterlab-pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1649936611996/work
jupyterlab-widgets==1.1.1
jupyterlab_server @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_server_1673884094295/work
keyring==23.11.0
keyrings.alt==4.2.0
kiwisolver==1.4.4
locket==1.0.0
Mako @ file:///home/conda/feedstock_root/build_artifacts/mako_1668568582731/work
MarkupSafe==2.1.1
matplotlib==3.6.2
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1660814786464/work
mistune @ file:///home/conda/feedstock_root/build_artifacts/mistune_1657892024508/work
more-itertools==9.0.0
mpl-interactions==0.22.0
multidict==6.0.2
natsort==8.2.0
nbclassic @ file:///home/conda/feedstock_root/build_artifacts/nbclassic_1667492839781/work
nbclient @ file:///home/conda/feedstock_root/build_artifacts/nbclient_1669795076334/work
nbconvert==7.2.5
nbformat==5.7.0
ndx-grayscalevolume==0.0.2
ndx-icephys-meta==0.1.0
ndx-spectrum==0.2.2
nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1664684991461/work
networkx==2.8.8
notebook==6.5.2
notebook_shim @ file:///home/conda/feedstock_root/build_artifacts/notebook-shim_1667478401171/work
nteract-on-jupyter==2.1.3
numcodecs==0.10.2
numpy==1.22.4
nwbinspector==0.4.20
nwbwidgets==0.10.0
oauthlib @ file:///home/conda/feedstock_root/build_artifacts/oauthlib_1666056362788/work
packaging==21.3
pamela==1.0.0
pandas==1.5.2
pandocfilters @ file:///home/conda/feedstock_root/build_artifacts/pandocfilters_1631603243851/work
param==1.12.2
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1638334955874/work
partd==1.3.0
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1667297516076/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
Pillow==9.3.0
pkgutil_resolve_name @ file:///home/conda/feedstock_root/build_artifacts/pkgutil-resolve-name_1633981968097/work
platformdirs==2.5.4
plotly==5.11.0
prometheus-client @ file:///home/conda/feedstock_root/build_artifacts/prometheus_client_1665692535292/work
prompt-toolkit==3.0.33
psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1667885878918/work
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pure-eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1642875951954/work
py2vega==0.6.1
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
pycryptodomex==3.16.0
pyct==0.4.8
pycurl==7.45.1
pydantic==1.10.2
Pygments==2.13.0
PyJWT @ file:///home/conda/feedstock_root/build_artifacts/pyjwt_1666240235902/work
pynwb==2.2.0
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1672659226110/work
pyout==0.7.2
pyparsing==3.0.9
pyrsistent==0.19.2
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1661604839144/work
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work
python-json-logger @ file:///home/conda/feedstock_root/build_artifacts/python-json-logger_1671655909697/work
pythreejs==2.4.1
pytz==2022.6
PyWavelets==1.4.1
PyYAML==6.0
pyzmq==24.0.1
qtconsole==5.4.0
QtPy==2.3.0
requests==2.28.1
rfc3339-validator==0.1.4
rfc3987==1.3.8
ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1666827402316/work
ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1670412724006/work
scikit-image==0.19.3
scipy==1.9.3
SecretStorage==3.3.3
semantic-version==2.10.0
Send2Trash @ file:///home/conda/feedstock_root/build_artifacts/send2trash_1628511208346/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
sniffio @ file:///home/conda/feedstock_root/build_artifacts/sniffio_1662051266223/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1658207591808/work
SQLAlchemy @ file:///home/conda/feedstock_root/build_artifacts/sqlalchemy_1672796143951/work
stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1669632077133/work
tenacity==8.1.0
terminado==0.17.0
tifffile==2022.10.10
tinycss2 @ file:///home/conda/feedstock_root/build_artifacts/tinycss2_1666100256010/work
tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1644342247877/work
toolz==0.12.0
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1666788592778/work
tqdm==4.64.1
traitlets==5.6.0
traittypes==0.2.1
trimesh==3.16.4
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1665144421445/work
uri-template==1.2.0
urllib3==1.26.13
wcwidth==0.2.5
webcolors==1.12
webencodings==0.5.1
websocket-client @ file:///home/conda/feedstock_root/build_artifacts/websocket-client_1667568040382/work
widgetsnbextension==3.6.1
wincertstore==0.2
xarray==2022.11.0
yarl==1.8.1
zarr==2.13.3
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1669453021653/work
zstandard==0.19.0
ianhi commented 1 year ago

@rcpeene can you link to an example binder that demonstrates this issue?

As it stands my first thought is that this is not an ipympl issue as ccf-widgets doesn't seem to use matplotlib (as you say it depends on itkwidgets)

rcpeene commented 1 year ago

Here is my binder notebook that I am using. It is worth noting that this works in Binder's Jupyter Classic but not Binder's JupyterLab

ianhi commented 1 year ago

That link doesn't work for me. Gives me this; Screenshot_20230209-105831

rcpeene commented 1 year ago

What about this? https://hub.gke2.mybinder.org/user/alleninstitute--nscope_databook-e0c54pkv/doc/tree/docs/visualization/visualize_neuropixel_probes.ipynb I think the link expires after a time.

ianhi commented 1 year ago

Same thing unfortunately. I would try opening the link you send in an incognito window - if it works for you in that then it will likely also work for me.

rcpeene commented 1 year ago

https://alleninstitute.github.io/openscope_databook/visualization/visualize_neuropixel_probes.html This should work. Press the Launch button in the top right and select Binder.

ianhi commented 1 year ago

Sometimes that binder actually works for me. But more significantly I think that this indeed confirms that this is not an ipympl issue, rather one with the CCFWidget. You see this as:

import sys
"ipympl" in sys.modules

will give False showing that ipympl was never imported. So for now I'm going to close this - but if you can confirm that ipympl is somehow causing this then please feel free to re-open.

I suggest that if you continue to have this issue you open an issue over on CCFWidget (https://github.com/NeurodataWithoutBorders/ccf-widget) or with whoever administers the binder you are using.