matplotlib / ipympl

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

Latest version of everything still causes the dreaded Error displaying widget: model not found #534

Closed davide-q closed 9 months ago

davide-q commented 1 year ago

Describe the issue

image

<rant> Wouldn't it be possible to provide a more meaningful error message that does not end up fooling google and providing outdated solutions of many, many versions ago? </rant>

Versions


 3.11.2 (main, Jul 28 2023, 17:26:47) [GCC 13.1.0]
ipympl version: 0.9.3
Selected Jupyter core packages...
IPython          : 8.15.0
ipykernel        : 6.25.2
ipywidgets       : 8.1.1
jupyter_client   : 8.3.1
jupyter_core     : 5.3.1
jupyter_server   : 2.7.3
jupyterlab       : 4.0.6
nbclient         : 0.8.0
nbconvert        : 7.8.0
nbformat         : 5.9.2
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.10.0
JupyterLab v4.0.6
~/venvs/generic_python-3.11.2/share/jupyter/labextensions
        jupyter-matplotlib v0.11.3 enabled OK
        jupyterlab_pygments v0.2.2 enabled  X (python, jupyterlab_pygments)
        @jupyter-widgets/jupyterlab-manager v5.0.9 enabled OK (python, jupyterlab_widgets)

   The following extensions are outdated:
        jupyterlab_pygments

   Consider checking if an update is available for these packages.
davide-q commented 1 year ago

PS: works fine in the traditional notebook interface, i.e. changing the URL from before/lab/tree/after to before/tree/after

JTem commented 1 year ago

Hi,

i had the same issue, i updated everything to the latest version, same issue.

i closed jupyterLab and restarted the pc and then it worked as expected. maybe that might help you too

davide-q commented 1 year ago

i closed jupyterLab and restarted the pc and then it worked as expected. maybe that might help you too

Thanks for the suggestion. Besides this being on a server (not a PC), anyway a reboot did not help.

ianhi commented 1 year ago

Hi @davide-q

is this running in a virtual environment (e.g. via conda/venv)? If so could you try in a freshly created environment to see if the issue persists?

When I create a new environment with: conda create -n ipympl-test -c conda-forge jupyterlab ipympl everything works for me with these versions:

 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]
ipympl version: 0.9.3
Selected Jupyter core packages...
IPython          : 8.15.0
ipykernel        : 6.25.2
ipywidgets       : 8.1.1
jupyter_client   : 8.3.1
jupyter_core     : 5.3.1
jupyter_server   : 2.7.3
jupyterlab       : 4.0.6
nbclient         : 0.8.0
nbconvert        : 7.8.0
nbformat         : 5.9.2
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.10.0
JupyterLab v4.0.6
/home/ian/mambaforge/envs/ipympl-test/share/jupyter/labextensions
        jupyter-matplotlib v0.11.3 enabled OK
        jupyterlab_pygments v0.2.2 enabled  X (python, jupyterlab_pygments)
        @jupyter-widgets/jupyterlab-manager v5.0.9 enabled OK (python, jupyterlab_widgets)

/home/ian/.local/share/jupyter/labextensions
        nbdime-jupyterlab v2.1.1 enabled  X

   The following extensions are outdated:
        jupyterlab_pygments
        nbdime-jupyterlab

   Consider checking if an update is available for these packages.

Wouldn't it be possible to provide a more meaningful error message that does not end up fooling google and providing outdated solutions of many, many versions ago?

Unfortunately that is not controlled by ipympl, rather by ipywidgets. You can see a PR that attempted to improve things here: https://github.com/jupyter-widgets/ipywidgets/pull/2960

davide-q commented 1 year ago

Thanks @ianhi -- yes, this is in a venv, and no creating a new one did not help (actually I had already tried that a few times, in case I was doing something incorrectly).

At this point, I suspect the root cause is this server being behind a firewall (which I have no control of) that is blocking something. It would be good to know what that "something" is, so I could ask the network people if they are okay opening it....

Thanks for pointing me to the PR, hopefully we will eventually get good messages.

ianhi commented 1 year ago

A good thing to check is if there are errors in your browser console

davide-q commented 1 year ago

Thanks again @ianhi -- I don't think that provides any useful information, but here it is.

While trying to run this cell, which fails as shown

image

The chrome console reports

image

While the jupyter console reports

image

As mentioned before in this ticket, the very same cell, on the very same jupyter install works just fine if I use the traditional interface rather than the jupyterlab by simply removing lab from the URL.

itsmejoeeey commented 1 year ago

I'm having this same issue too.

Environment:

Windows 11
`python`: 3.12.0
`pip`: 23.2.1

requirements.txt:

ipympl==0.9.3
notebook==7.0.6
matplotlib==3.8.2

Setup:

py -m venv .\.venv
.\.venv\Scripts\activate
pip install -r .\requirements.txt -y
jupyter notebook --notebook-dir=".\notebooks"

After opening my notebook:

image

Console errors:

Error: widget model not found
    get_model http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1
    renderModel http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25:1
[134.a63a8d293fb35a52dc25.js:1:72266](http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25)
    renderModel http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25:1

Please let me know if there is any further information I can provide.

ogauthe commented 10 months ago

Same problem here. ipympl can be loaded in console, not in jupyter lab. This prevents using %matplotlib widget. Another user recently reported this in #132 .

davide-q commented 9 months ago

I still have not figured out why this is happening, but I re-installed everything in two different environments (server and kernel) and the reinstallation with the latest-and-greatest work. It would be nice to know what is causing the issue (which is still there in the old environments), but probably life's too short for that and having new environments where it work may be good enough for people.

martinRenou commented 9 months ago

Great that you could have an environment where it works. It's good to try with an environment with the least packages possible, and progressively install stuffs to find the culprit.

It turns out that some extensions like jupyter-bokeh breaks widgets as of today. Probably things will be better soonish.