ipympl: Failed to load model class 'MPLCanvasModel' from module 'jupyter-matplotlib'
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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 35 (5 by maintainers)
I am experiencing a very similar issue: In a new environment with
ipympl==0.9.2,ipywidgets==8.0.2initially the matplotlib figure is displayed correctly in Jupyterlab with the minimal example: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:
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.Why is this issue closed? Clearly people (including myself) are still getting this problem
Thank you so much for sharing! I’ve been trying for a few days now to fix the interactive Jupyter plot environment issue and had absolutely no luck until I saw this solution. I am working on an Azure ML compute instance (VM).
For anyone else still running into the issue, the following helped me in addition to the quoted solution:
pip uninstall ipymplorconda uninstall ipymplin both environments afterjupyter lab clean --allcondato install jupyterlab in the base environment (I usedconda install -c conda-forge jupyterlab=3.2.4)condato install ipympl in the kernel environment (I usedconda install -c conda-forge ipympl=0.8.7)Not sure how my jupyter got into this state, but for me what solved this once and for all was:
jupyter lab build(in same terminal)Hope this helps someone else!
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?
This uses
jupyterlab-widgets==3.0.2on the JupyterLab environment (we have 2 separate environments because we’re using https://github.com/jupyter-server/enterprise_gateway/).Hi @dbl001 it looks as though you have the newest labextension but not the latest python version. Can you please update the python version:
pip install --upgrade ipympland try againBoth @Gilthans and @niwilso answers were helpful. I also had to install the latest version of nodejs (
mamba install nodejs)I had the problem mentioned by the poster but got it to work again.
Problem Description:
Attempts to fix it…
The fix…
I don’t see any obvious issue here.
Can you make sure to hard refresh your browser page (
ctrl + shift + R), just in case, and try again to run the Notebook cell?