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.

Failed to load model class 'MPLCanvasModel' from module 'jupyter-matplotlib'

See original GitHub issue

Describe the issue

This example plot is failing:

%matplotlib ipympl
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(3*x)
ax.plot(x, y)

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'MPLCanvasModel' from module 'jupyter-matplotlib'
Error: No version of module jupyter-matplotlib is registered
    at WidgetManager.loadClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/lib_index_js.c47facf974cffc1de06d.js:942:19)
    at WidgetManager.loadModelClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/packages_base-manager_lib_index_js.dcca134bd5d3eec26948.js:819:34)
    at WidgetManager._make_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/packages_base-manager_lib_index_js.dcca134bd5d3eec26948.js:651:36)
    at WidgetManager.new_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/packages_base-manager_lib_index_js.dcca134bd5d3eec26948.js:495:35)
    at WidgetManager.handle_comm_open (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/packages_base-manager_lib_index_js.dcca134bd5d3eec26948.js:405:21)
    at LabWidgetManager._handleCommOpen (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/lib_index_js.c47facf974cffc1de06d.js:815:24)
    at b._handleCommOpen (http://localhost:8888/static/lab/jlab_core.3ff62e44d3544d23c59e.js?v=3ff62e44d3544d23c59e:2:925131)
    at async b._handleMessage (http://localhost:8888/static/lab/jlab_core.3ff62e44d3544d23c59e.js?v=3ff62e44d3544d23c59e:2:927121)

Versions


 3.8.5 (default, Sep  4 2020, 02:22:02) 
[Clang 10.0.0 ]
ipympl version: 0.8.8
Selected Jupyter core packages...
IPython          : 7.28.0
ipykernel        : 6.4.1
ipywidgets       : 8.0.0rc0
jupyter_client   : 7.0.6
jupyter_core     : 4.8.1
jupyter_server   : 1.11.1
jupyterlab       : 3.1.18
nbclient         : 0.5.4
nbconvert        : 6.2.0
nbformat         : 5.1.3
notebook         : 6.4.4
qtconsole        : not installed
traitlets        : 5.1.0
Known nbextensions:
  config dir: /Users/davidlaxer/.jupyter/nbconfig
    notebook section
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
      bqplot/extension  enabled 
      - Validating: OK
  config dir: /Users/davidlaxer/tensorflow-metal/etc/jupyter/nbconfig
    notebook section
      catboost-widget/extension  enabled 
      - Validating: OK
      jupyter-matplotlib/extension  enabled 
      - Validating: OK
      jupyterlab-plotly/extension  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
JupyterLab v3.1.18
/Users/davidlaxer/tensorflow-metal/share/jupyter/labextensions
        @jupyter-widgets/jupyterlab-manager v5.0.0-rc.0 enabled OK

Other labextensions (built into JupyterLab)
   app dir: /Users/davidlaxer/tensorflow-metal/share/jupyter/lab
        jupyter-matplotlib v0.11.0 enabled OK
        jupyterlab-plotly v5.7.0 enabled OK


Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:24 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
asteppkecommented, Oct 12, 2022

I am experiencing a very similar issue: In a new environment with ipympl==0.9.2, ipywidgets==8.0.2 initially the matplotlib figure is displayed correctly in Jupyterlab with the minimal example:

%matplotlib ipympl
from matplotlib import pyplot as plt
fig, ax = plt.subplots()

A different extension needed an update though and that triggered a Jupyterlab build. After the build finished without errors the same example only yields the error message in the cell output:

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'MPLCanvasModel' from module 'jupyter-matplotlib'
Error: No version of module jupyter-matplotlib is registered
    at f.loadClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.bcbea9feb6e7c4da7530.js?v=bcbea9feb6e7c4da7530:1:74856)
    at f.loadModelClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.3e1e5adfd821b9b96340.js?v=3e1e5adfd821b9b96340:1:10729)
    at f._make_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.3e1e5adfd821b9b96340.js?v=3e1e5adfd821b9b96340:1:7517)
    at f.new_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.3e1e5adfd821b9b96340.js?v=3e1e5adfd821b9b96340:1:5137)
    at f.handle_comm_open (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.3e1e5adfd821b9b96340.js?v=3e1e5adfd821b9b96340:1:3894)
    at _handleCommOpen (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.bcbea9feb6e7c4da7530.js?v=bcbea9feb6e7c4da7530:1:73393)
    at b._handleCommOpen (http://localhost:8888/static/lab/jlab_core.005d4a04b448c938e176.js?v=005d4a04b448c938e176:2:996724)
    at async b._handleMessage (http://localhost:8888/static/lab/jlab_core.005d4a04b448c938e176.js?v=005d4a04b448c938e176:2:998714)

This seems to indicate that something is still not working in the built process. This reminds me of similar issues in the past where in a new environment everything worked but for unclear reasons after an update it became impossible to recover.

A workaround seems to be the complete cycle of conda uninstall jupyterlab ipympl, conda install -c conda-forge jupyterlab ipympl. Just reinstalling ipympl is not enough.

3reactions
astrojuanlucommented, Aug 30, 2022

I’m still experiencing this issue with ipywidgets 8.0.1 and ipympl 0.9.2, which is the latest release and includes gh-461. Should I open a new one, or continue the conversation here?

ipympl-failing

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'MPLCanvasModel' from module 'jupyter-matplotlib'
loadClass@https://festive-panini-317af3ac.orchestapp.io/jupyter-server-073b702f-bc66-44c1c87bb737-6ba5-4013/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.083e6b37f2f7b2f04b5e.js?v=083e6b37f2f7b2f04b5e:1:74855
loadModelClass@https://festive-panini-317af3ac.orchestapp.io/jupyter-server-073b702f-bc66-44c1c87bb737-6ba5-4013/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.467514c324d2bcc23502.js?v=467514c324d2bcc23502:1:10721
_make_model@https://festive-panini-317af3ac.orchestapp.io/jupyter-server-073b702f-bc66-44c1c87bb737-6ba5-4013/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.467514c324d2bcc23502.js?v=467514c324d2bcc23502:1:7517
new_model@https://festive-panini-317af3ac.orchestapp.io/jupyter-server-073b702f-bc66-44c1c87bb737-6ba5-4013/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.467514c324d2bcc23502.js?v=467514c324d2bcc23502:1:5137
handle_comm_open@https://festive-panini-317af3ac.orchestapp.io/jupyter-server-073b702f-bc66-44c1c87bb737-6ba5-4013/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.467514c324d2bcc23502.js?v=467514c324d2bcc23502:1:3894
134/v/this._handleCommOpen@https://festive-panini-317af3ac.orchestapp.io/jupyter-server-073b702f-bc66-44c1c87bb737-6ba5-4013/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.083e6b37f2f7b2f04b5e.js?v=083e6b37f2f7b2f04b5e:1:73392
_handleCommOpen@https://festive-panini-317af3ac.orchestapp.io/jupyter-server-073b702f-bc66-44c1c87bb737-6ba5-4013/static/lab/jlab_core.a8a3519a137e0ddfc2a4.js?v=a8a3519a137e0ddfc2a4:2:1066903

This uses jupyterlab-widgets==3.0.2 on the JupyterLab environment (we have 2 separate environments because we’re using https://github.com/jupyter-server/enterprise_gateway/).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jupyter Lab issue displaying widgets (javascript error)
I checked that jupyter-widgets is enable with jupyter labextension list. ... message] Failed to load model class 'CheckboxModel' from module ...
Read more >
ipympl - Matplotlib
ipympl enables using the interactive features of matplotlib in Jupyter Notebooks, Jupyter Lab, Google Colab, VSCode notebooks, Google Colab.
Read more >
Error displaying widget: model not found -- how to fix this?
So as to use Stacked, I installed version 8: > pip uninstall ipywidgets > pip install ipywidgets==8.0.0b But upon displaying a Stacked ...
Read more >
Using Matplotlib with Jupyter Notebook - GeeksforGeeks
The Jupyter Notebook is an open-source web application that allows you to create and share documents that ... importing matplotlib module.
Read more >
Error fixed - "matplotlib.pyplot" not resolved from source. in ...
Hello Friends, In this tutorial session we will see the quick fix of the common error that comes when we work with Jupyter...
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