ipympl icon indicating copy to clipboard operation
ipympl copied to clipboard

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

Open dbl001 opened this issue 2 years ago • 15 comments

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


dbl001 avatar Apr 15 '22 15:04 dbl001

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 ipympl and try again

ianhi avatar Apr 15 '22 15:04 ianhi

Ok. There's also weird behavior where if the matplotlib works then all the other widgets output text instead of displaying properly. E.g. -

slider = widgets.IntSlider()
text = widgets.IntText()

@throttle(0.2)
def value_changed(change):
    text.value = change.new
slider.observe(value_changed, 'value')

widgets.VBox([slider, text])
...
VBox(children=(IntSlider(value=0), IntText(value=0)))

The behavior appears to be either matplotlib works or the other widgets work.

dbl001 avatar Apr 15 '22 15:04 dbl001

% pip install --upgrade ipympl
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
Requirement already satisfied: ipympl in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (0.8.8)
Collecting ipympl
  Downloading ipympl-0.9.0-py2.py3-none-any.whl (508 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 508.6/508.6 KB 3.0 MB/s eta 0:00:00
Requirement already satisfied: matplotlib<4,>=3.4.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipympl) (3.4.3)
Requirement already satisfied: ipython-genutils in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipympl) (0.2.0)
Requirement already satisfied: pillow in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipympl) (8.3.2)
Requirement already satisfied: numpy in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipympl) (1.20.3)
Requirement already satisfied: ipython<9 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipympl) (7.28.0)
Collecting ipywidgets<8,>=7.6.0
  Using cached ipywidgets-7.7.0-py2.py3-none-any.whl (123 kB)
Requirement already satisfied: traitlets<6 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipympl) (5.1.0)
Requirement already satisfied: decorator in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (5.1.0)
Requirement already satisfied: pickleshare in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (0.7.5)
Requirement already satisfied: pygments in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (2.10.0)
Requirement already satisfied: jedi>=0.16 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (0.18.0)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (3.0.20)
Requirement already satisfied: appnope in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (0.1.2)
Requirement already satisfied: pexpect>4.3 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (4.8.0)
Requirement already satisfied: matplotlib-inline in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (0.1.3)
Requirement already satisfied: setuptools>=18.5 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (62.0.0)
Requirement already satisfied: backcall in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipython<9->ipympl) (0.2.0)
Collecting widgetsnbextension~=3.6.0
  Using cached widgetsnbextension-3.6.0-py2.py3-none-any.whl (1.6 MB)
Requirement already satisfied: nbformat>=4.2.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipywidgets<8,>=7.6.0->ipympl) (5.1.3)
Requirement already satisfied: jupyterlab-widgets>=1.0.0 in /Users/davidlaxer/ipywidgets/python/jupyterlab_widgets (from ipywidgets<8,>=7.6.0->ipympl) (3.0.0rc0)
Requirement already satisfied: ipykernel>=4.5.1 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipywidgets<8,>=7.6.0->ipympl) (6.4.1)
Requirement already satisfied: python-dateutil>=2.7 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from matplotlib<4,>=3.4.0->ipympl) (2.8.2)
Requirement already satisfied: kiwisolver>=1.0.1 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from matplotlib<4,>=3.4.0->ipympl) (1.3.2)
Requirement already satisfied: pyparsing>=2.2.1 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from matplotlib<4,>=3.4.0->ipympl) (2.4.7)
Requirement already satisfied: cycler>=0.10 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from matplotlib<4,>=3.4.0->ipympl) (0.10.0)
Requirement already satisfied: six in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from cycler>=0.10->matplotlib<4,>=3.4.0->ipympl) (1.15.0)
Requirement already satisfied: jupyter-client<8.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipympl) (7.0.6)
Requirement already satisfied: tornado<7.0,>=4.2 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipympl) (6.1)
Requirement already satisfied: debugpy<2.0,>=1.0.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipympl) (1.5.0)
Requirement already satisfied: parso<0.9.0,>=0.8.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from jedi>=0.16->ipython<9->ipympl) (0.8.2)
Requirement already satisfied: jupyter-core in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipympl) (4.8.1)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipympl) (4.0.1)
Requirement already satisfied: ptyprocess>=0.5 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from pexpect>4.3->ipython<9->ipympl) (0.7.0)
Requirement already satisfied: wcwidth in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython<9->ipympl) (0.2.5)
Requirement already satisfied: notebook>=4.4.1 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (6.4.4)
Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipympl) (0.18.0)
Requirement already satisfied: attrs>=17.4.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipympl) (21.2.0)
Requirement already satisfied: entrypoints in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipympl) (0.3)
Requirement already satisfied: nest-asyncio>=1.5 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipympl) (1.5.1)
Requirement already satisfied: pyzmq>=13 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipympl) (22.3.0)
Requirement already satisfied: nbconvert in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (6.2.0)
Requirement already satisfied: jinja2 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (3.0.2)
Requirement already satisfied: Send2Trash>=1.5.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (1.8.0)
Requirement already satisfied: terminado>=0.8.3 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (0.12.1)
Requirement already satisfied: argon2-cffi in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (21.1.0)
Requirement already satisfied: prometheus-client in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (0.11.0)
Requirement already satisfied: cffi>=1.0.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (1.14.6)
Requirement already satisfied: MarkupSafe>=2.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from jinja2->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (2.0.1)
Requirement already satisfied: testpath in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (0.5.0)
Requirement already satisfied: defusedxml in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (0.7.1)
Requirement already satisfied: mistune<2,>=0.8.1 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (0.8.4)
Requirement already satisfied: jupyterlab-pygments in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (0.1.2)
Requirement already satisfied: pandocfilters>=1.4.1 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (1.5.0)
Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (0.5.4)
Requirement already satisfied: bleach in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (4.1.0)
Requirement already satisfied: pycparser in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from cffi>=1.0.0->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (2.20)
Requirement already satisfied: packaging in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (21.0)
Requirement already satisfied: webencodings in /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8,>=7.6.0->ipympl) (0.5.1)
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
Installing collected packages: widgetsnbextension, ipywidgets, ipympl
  Attempting uninstall: widgetsnbextension
    WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
    Found existing installation: widgetsnbextension 4.0.0rc0
    Uninstalling widgetsnbextension-4.0.0rc0:
      Successfully uninstalled widgetsnbextension-4.0.0rc0
  Attempting uninstall: ipywidgets
    WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
    Found existing installation: ipywidgets 8.0.0rc0
    Uninstalling ipywidgets-8.0.0rc0:
      Successfully uninstalled ipywidgets-8.0.0rc0
  Attempting uninstall: ipympl
    WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
    Found existing installation: ipympl 0.8.8
    Uninstalling ipympl-0.8.8:
      Successfully uninstalled ipympl-0.8.8
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
Successfully installed ipympl-0.9.0 ipywidgets-7.7.0 widgetsnbextension-3.6.0
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
(tensorflow-metal) (base) davidlaxer@x86_64-apple-darwin13 top2vec % 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.5 (default, Sep  4 2020, 02:22:02) 
[Clang 10.0.0 ]
ipympl version: 0.9.0
Selected Jupyter core packages...
IPython          : 7.28.0
ipykernel        : 6.4.1
ipywidgets       : 7.7.0
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-matplotlib v0.11.0 enabled OK
        @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
        jupyterlab-plotly v5.7.0 enabled OK

(tensorflow-metal) (base) davidlaxer@x86_64-apple-darwin13 top2vec % 

dbl001 avatar Apr 15 '22 16:04 dbl001

    @jupyter-widgets/jupyterlab-manager v5.0.0-rc.0 enabled OK

This looks like the the widgets version 8 manager. Currentl ipympl requires ipywidgets< 8 but somehow that's not getting cleared. If you can get the javascript of ipywidgets back to pre version 8 it should fixes things. But that's just a workaround, we really need to just update our requirements (which will require testing for the new ipywidgets

ianhi avatar Apr 15 '22 16:04 ianhi

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)

dbl001 avatar Apr 15 '22 16:04 dbl001

... one additional problem ... the matplotlib wordcloud displays outside this function but NOT inside. Any ideas?

#%matplotlib widgets
#%matplotlib inline
#%matplotlib ipympl

keywords_select_st = widgets.Label('Enter keywords seperated by space: ')
display(keywords_select_st)

keywords_input_st = widgets.Text()
display(keywords_input_st)

keywords_neg_select_st = widgets.Label('Enter negative keywords seperated by space: ')
display(keywords_neg_select_st)

keywords_neg_input_st = widgets.Text()
display(keywords_neg_input_st)

doc_num_select_st = widgets.Label('Choose number of topics: ')
display(doc_num_select_st)

doc_num_input_st = widgets.Text(value='5')
display(doc_num_input_st)

def display_similar_topics(*args):
    with output:
        clear_output()
        display(keywords_select_st)
        display(keywords_input_st)
        display(keywords_neg_select_st)
        display(keywords_neg_input_st)
        display(doc_num_select_st)
        display(doc_num_input_st)
        display(keyword_btn_st)
    
        try:
            topic_words, word_scores, topic_scores, topic_nums = top2vec.search_topics(keywords=keywords_input_st.value.split(),num_topics=int(doc_num_input_st.value), keywords_neg=keywords_neg_input_st.value.split())
            for topic in topic_nums:
                print(topic)
                top2vec.generate_topic_wordcloud(topic, background_color="black")

        except Exception as e:
            print("Exception: ...")
            print(e)
        
keyword_btn_st = widgets.Button(description="show topics")
output = widgets.Output()
display(keyword_btn_st, output)
keyword_btn_st.on_click(display_similar_topics)

This is outside the function Screen Shot 2022-04-15 at 9 29 29 AM

dbl001 avatar Apr 15 '22 16:04 dbl001

That looks like the title is getting cut off from the matplotlib figure. That's related to how matplotlib renders rather than ipympl. You can probably fix it by resizing or using either plt.figure(constrained_layout=True) or calling plt.tight_layout()

ianhi avatar Apr 15 '22 16:04 ianhi

If #461 passes then I'll make a new release that will work with ipywidgets 8.

ianhi avatar Apr 15 '22 16:04 ianhi

I get these errors with ipywidgets==7.7.0

Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'VBoxModel' from module '@jupyter-widgets/controls'
Error: Module @jupyter-widgets/controls, version ^1.5.0 is not registered, however,         2.0.0 is
    at WidgetManager.loadClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/lib_index_js.c47facf974cffc1de06d.js:947: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)
%matplotlib ipympl
import matplotlib.pyplot as plt

Here my configuration:

 % 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.5 (default, Sep  4 2020, 02:22:02) 
[Clang 10.0.0 ]
ipympl version: 0.9.0
Selected Jupyter core packages...
IPython          : 7.28.0
ipykernel        : 6.4.1
ipywidgets       : 7.7.0
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-matplotlib v0.11.0 enabled OK
        @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
        jupyterlab-plotly v5.7.0 enabled OK

(tensorflow-metal) (base) davidlaxer@x86_64-apple-darwin13 top2vec % pip show ipywidgets              
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
Name: ipywidgets
Version: 7.7.0
Summary: IPython HTML widgets for Jupyter
Home-page: http://ipython.org
Author: IPython Development Team
Author-email: [email protected]
License: BSD
Location: /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages
Requires: ipykernel, ipython, ipython-genutils, jupyterlab-widgets, nbformat, traitlets, widgetsnbextension
Required-by: ipympl
(tensorflow-metal) (base) davidlaxer@x86_64-apple-darwin13 top2vec % jupyter labextension list                                           
JupyterLab v3.1.18
/Users/davidlaxer/tensorflow-metal/share/jupyter/labextensions
        jupyter-matplotlib v0.11.0 enabled OK
        @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
        jupyterlab-plotly v5.7.0 enabled OK


dbl001 avatar Apr 15 '22 20:04 dbl001

I get these errors with ipywidgets==7.7.0

Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'VBoxModel' from module '@jupyter-widgets/controls'
Error: Module @jupyter-widgets/controls, version ^1.5.0 is not registered, however,         2.0.0 is
    at WidgetManager.loadClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/lib_index_js.c47facf974cffc1de06d.js:947: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)
%matplotlib ipympl
import matplotlib.pyplot as plt

Here my configuration:

 % 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.5 (default, Sep  4 2020, 02:22:02) 
[Clang 10.0.0 ]
ipympl version: 0.9.0
Selected Jupyter core packages...
IPython          : 7.28.0
ipykernel        : 6.4.1
ipywidgets       : 7.7.0
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-matplotlib v0.11.0 enabled OK
        @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
        jupyterlab-plotly v5.7.0 enabled OK

(tensorflow-metal) (base) davidlaxer@x86_64-apple-darwin13 top2vec % pip show ipywidgets              
WARNING: Ignoring invalid distribution -umpy (/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages)
Name: ipywidgets
Version: 7.7.0
Summary: IPython HTML widgets for Jupyter
Home-page: http://ipython.org
Author: IPython Development Team
Author-email: [email protected]
License: BSD
Location: /Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages
Requires: ipykernel, ipython, ipython-genutils, jupyterlab-widgets, nbformat, traitlets, widgetsnbextension
Required-by: ipympl
(tensorflow-metal) (base) davidlaxer@x86_64-apple-darwin13 top2vec % jupyter labextension list                                           
JupyterLab v3.1.18
/Users/davidlaxer/tensorflow-metal/share/jupyter/labextensions
        jupyter-matplotlib v0.11.0 enabled OK
        @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
        jupyterlab-plotly v5.7.0 enabled OK


dbl001 avatar Apr 19 '22 13:04 dbl001

Any updates on getting ipywidgets : 8.0.0rc0 with matplotlib or alternatively a way to get ipwidgets 7.7.0 work?

dbl001 avatar Apr 19 '22 13:04 dbl001

Even if using ipywidgets 7.7, if you still have @jupyter-widgets/jupyterlab-manager v5.0.0-rc.0 around it will not work.

I would suggest starting again from a clean environment and installing latest ipympl with ipywidgets 7.7.

Any updates on getting ipywidgets : 8.0.0rc0 with matplotlib

ipywidgets 8 is coming very soon, we'll make sure to update ipympl to have ipywidgets 8 support soonish after the ipywidgets release.

martinRenou avatar Apr 20 '22 09:04 martinRenou

Can you send me the output of on an environment where ipywidgets + matplotlib is working:

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

dbl001 avatar Apr 20 '22 14:04 dbl001

 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:38:57) [GCC 10.3.0]
ipympl version: 0.9.0
Selected Jupyter core packages...
IPython          : 8.2.0
ipykernel        : 6.13.0
ipywidgets       : 7.7.0
jupyter_client   : 7.2.2
jupyter_core     : 4.9.2
jupyter_server   : 1.16.0
jupyterlab       : 3.3.4
nbclient         : 0.6.0
nbconvert        : 6.5.0
nbformat         : 5.3.0
notebook         : 6.4.11
qtconsole        : not installed
traitlets        : 5.1.1

JupyterLab v3.3.4
/home/martin/miniconda3/envs/ipympl/share/jupyter/labextensions
        jupyterlab-night v0.4.3 enabled OK (python, jupyterlab_night)
        jupyterlab-unfold v0.2.2 enabled OK (python, jupyterlab-unfold)
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        jupyter-matplotlib v0.11.0 enabled OK
        @jupyter-widgets/jupyterlab-manager v3.1.0 enabled OK (python, jupyterlab_widgets)

martinRenou avatar Apr 20 '22 14:04 martinRenou

% 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.5 (default, Sep  4 2020, 02:22:02) 
[Clang 10.0.0 ]
ipympl version: 0.9.0
Selected Jupyter core packages...
IPython          : 8.2.0
ipykernel        : 6.13.0
ipywidgets       : 7.7.0
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-matplotlib v0.11.0 enabled OK

Other labextensions (built into JupyterLab)
   app dir: /Users/davidlaxer/tensorflow-metal/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v3.1.0 enabled OK
        jupyterlab-plotly v5.7.0 enabled OK

Here's a test:

import ipywidgets as widgets
from IPython.display import display

a = widgets.IntSlider(value=5, min=0, max=10)

def f1(a):
    display(a)
    
def f2(a):
    display(a * 2)
    
out1 = widgets.interactive_output(f1, {'a': a})
out2 = widgets.interactive_output(f2, {'a': a})

display(a)
display(out1)
display(out2)

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'IntSliderModel' from module '@jupyter-widgets/controls'
Error: Module @jupyter-widgets/controls, version ^1.5.0 is not registered, however,         2.0.0 is
    at WidgetManager.loadClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/lib_index_js.c47facf974cffc1de06d.js:947: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)
5
10

And for matplotlib:

%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)
%matplotlib widget
import matplotlib.pyplot as plt

dbl001 avatar Apr 20 '22 15:04 dbl001

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/).

astrojuanlu avatar Aug 30 '22 08:08 astrojuanlu

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.

asteppke avatar Oct 12 '22 13:10 asteppke

A different extension needed an update though and that triggered a Jupyterlab build

Can you provide more context on this?

Also can you give us the output of jupyter labextension list

martinRenou avatar Oct 12 '22 15:10 martinRenou

@martinRenou: Thank you for looking into this!

The output of jupyter labextension list:

Config option `kernel_spec_manager_class` not recognized by `ListLabExtensionsApp`.
[W 2022-10-12 17:39:02.088 LabApp] Config option `kernel_spec_manager_class` not recognized by `LabApp`.
JupyterLab v3.4.8
C:\tools\miniconda3\envs\jupyter\share\jupyter\labextensions
        jupyter-matplotlib v0.11.2 enabled ok
        jupyterlab-jupytext v1.3.8+dev enabled ok (python, jupytext)
        jupyterlab_pygments v0.2.2 enabled ok (python, jupyterlab_pygments)
        @jupyter-widgets/jupyterlab-manager v5.0.3 enabled ok (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: C:\tools\miniconda3\envs\jupyter\share\jupyter\lab
        @aquirdturtle/collapsible_headings v3.0.0 enabled ok
        @jupyterlab/debugger v3.0.12 enabled ok


Build recommended, please run `jupyter lab build`:
    @aquirdturtle/collapsible_headings needs to be included in build

As you can see the collapsible_headings extension would like that I trigger a jupyter lab build. If I do that though the built completes without error messages but ipympl is broken with the message given above.

The jupyter lab build output indicates no issues:

[LabBuildApp] WARNING | Config option `kernel_spec_manager_class` not recognized by `LabBuildApp`.
[LabBuildApp] JupyterLab 3.4.8
[LabBuildApp] Building in C:\tools\miniconda3\envs\jupyter\share\jupyter\lab
[LabBuildApp] Building jupyterlab assets (production, minimized)
\

asteppke avatar Oct 12 '22 15:10 asteppke

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?

martinRenou avatar Oct 12 '22 15:10 martinRenou

I tried a hard refresh as you suggested, also a different browser (Chrome and Edge), and restarted JupyterLab but the issue remains.

asteppke avatar Oct 12 '22 16:10 asteppke

I experienced a similar issue and was able to fix it by manually installing the lab extension like in https://github.com/matplotlib/ipympl#use-in-jupyterlab.

camelid avatar Nov 23 '22 23:11 camelid

Also getting this Javascript error with Jupyer Lab 3.5.1 (using the example notebook from this repo). Should this issue be reopened and looked at again?

Console error: Error: No version of module jupyter-matplotlib is registered

Package Version


anyio 3.6.2 appdirs 1.4.4 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 arrow 1.2.3 astor 0.8.1 asttokens 2.2.1 attrs 22.1.0 Babel 2.11.0 backcall 0.2.0 beautifulsoup4 4.11.1 bleach 5.0.1 certifi 2022.9.24 cffi 1.15.1 charset-normalizer 2.1.1 contexttimer 0.3.3 contourpy 1.0.6 cycler 0.11.0 debugpy 1.6.4 decorator 5.1.1 defusedxml 0.7.1 duckdb 0.6.1 duckdb-engine 0.6.5 entrypoints 0.4 et-xmlfile 1.1.0 evdev 1.6.0 executing 1.2.0 fastjsonschema 2.16.2 fonttools 4.38.0 fqdn 1.5.1 greenlet 2.0.1 idna 3.4 ipykernel 6.17.1 ipympl 0.9.2 ipython 8.7.0 ipython-genutils 0.2.0 ipython-sql 0.4.1 ipywidgets 8.0.3 isoduration 20.11.0 jedi 0.18.2 Jinja2 3.1.2 joblib 1.2.0 json5 0.9.10 jsonpointer 2.3 jsonschema 4.17.3 jupyter_client 7.4.8 jupyter_core 5.1.0 jupyter-events 0.5.0 jupyter_server 2.0.0 jupyter_server_terminals 0.4.2 jupyterlab 3.5.1 jupyterlab-pygments 0.2.2 jupyterlab_server 2.16.3 jupyterlab-widgets 3.0.3 kiwisolver 1.4.4 lesscpy 0.15.1 MarkupSafe 2.1.1 matplotlib 3.6.2 matplotlib-inline 0.1.6 mistune 2.0.4 nbclassic 0.4.8 nbclient 0.7.2 nbconvert 7.2.6 nbformat 5.7.0 nest-asyncio 1.5.6 nhanes 0.5.1 notebook 6.5.2 notebook_shim 0.2.2 numpy 1.23.5 openpyxl 3.0.10 packaging 21.3 pandas 1.5.2 pandocfilters 1.5.0 parso 0.8.3 patsy 0.5.3 pexpect 4.8.0 pickleshare 0.7.5 Pillow 9.3.0 pip 22.0.2 platformdirs 2.6.0 plotly 5.11.0 ply 3.11 prettytable 0.7.2 prometheus-client 0.15.0 prompt-toolkit 3.0.36 psutil 5.9.4 ptyprocess 0.7.0 pure-eval 0.2.2 pyarrow 10.0.1 pycparser 2.21 Pygments 2.13.0 pynput 1.7.6 pyparsing 3.0.9 PyQt5 5.15.7 PyQt5-Qt5 5.15.2 PyQt5-sip 12.11.0 PyQtWebEngine 5.15.6 PyQtWebEngine-Qt5 5.15.2 pyrsistent 0.19.2 python-dateutil 2.8.2 python-json-logger 2.0.4 python-xlib 0.32 pytz 2022.6 PyYAML 6.0 pyzmq 24.0.1 qtstylish 0.1.5 requests 2.28.1 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 scikit-learn 1.1.3 scipy 1.9.3 seaborn 0.12.1 Send2Trash 1.8.0 setuptools 59.6.0 simpy 4.0.1 six 1.16.0 sklearn 0.0.post1 sniffio 1.3.0 soupsieve 2.3.2.post1 SQLAlchemy 1.4.44 sqlparse 0.4.3 stack-data 0.6.2 statsmodels 0.13.5 tenacity 8.1.0 terminado 0.17.1 threadpoolctl 3.1.0 tinycss2 1.2.1 tomli 2.0.1 tornado 6.2 traitlets 5.6.0 typing_extensions 4.4.0 uri-template 1.2.0 urllib3 1.26.13 wcwidth 0.2.5 webcolors 1.12 webencodings 0.5.1 websocket-client 1.4.2 wheel 0.38.4 widgetsnbextension 4.0.3 wordcloud 1.8.2.2 wquantiles 0.6

dat-linux avatar Dec 08 '22 11:12 dat-linux

The error only occurs in Jupyterlab, not when using Jupyter notebook. Any idea how to force github to open in jupyter notebook instead of jupyterlab?

SinaDavid avatar Dec 20 '22 10:12 SinaDavid

I also have trouble with it. Using JupyterLab v3.5.2, Console Error Error: No version of module jupyter-matplotlib is registered

anamyk avatar Jan 06 '23 17:01 anamyk

So now its working for me (Ubuntu 20.04). I am not sure what was wrong, although I had jupyter and jupyterlab installed. I uninstalled both, and also the accompanying packages (for the noobs like me, you see them with pip3 list, scroll to all jupyter* packages). Then I purged the pip3 cache pip3 cache purge. Reinstall with pip3 install jupyterlab, then pip3 install matplotlib, pip3 install matplotlib, pip3 install ipywidgets, pip3 install ipympl.

Restart jupyterlab from termial and if your didnt close your jupyter-lab tab, do a hard reload (Shift + Ctrl + r).

anamyk avatar Jan 06 '23 19:01 anamyk

I am experiencing the same issue. Specifically, using ipywidgets 7.7.2 and ipympl 0.9.2 with jupyterlab 3.5.2, if I try to plot in a JupyterLab notebook cell after %matplotlib widget I get:

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.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2:994257)
    at async b._handleMessage (http://localhost:8888/static/lab/jlab_core.081dc2b13065c79d8463.js?v=081dc2b13065c79d8463:2:996247)

sammlapp avatar Jan 11 '23 19:01 sammlapp

I had the problem mentioned by the poster but got it to work again.

  • Using Python 3.9.12, Conda 22.11.1 in WSL

Problem Description:

  • widgets would not work correctly (non-interactable figures) in Jupyter Notebook and I got the " MPLCanvasModel" error in Jupyter Lab with no cell output (only error)

Attempts to fix it...

  • I tried to install widgets using the Jupyterlab 3 installation instructions shown here https://ipywidgets.readthedocs.io/en/7.x/user_install.html
  • I used (conda install nodejs -c conda-forge --repodata-fn=repodata.json) to get the latest version of nodejs
  • It didn't work so I also tried the installation instruction for JYL2 as well with (jupyter labextension install @jupyter-widgets/jupyterlab-manager) in both my base environment and other environments (was a mistake)
  • When I used (jupyter labextension list) in both my base and separate environments I saw
  • (@jupyter-widgets/jupyterlab-manager v3.1.1 enabled OK (python, jupyterlab_widgets)) in other environment
  • and ( @jupyter-widgets/jupyterlab-manager v5.0.5 enabled OK (python, jupyterlab_widgets)) in base environment
  • This made me suspect that there were conflicting versions of jupyterlab-manager for different environments.

The fix....

  • I sought to remove my extensions so I used (jupyter lab clean --all) in both environments
  • Then I uninstalled jupyterlab from my base and other environment using (conda uninstall jupyterlab)
  • Then I reinstalled jupyterlab in my base environment (only) and reinstalled widgets in the environments I wanted to use
  • This seemed to fix the issue and now I can interact with my figures in jupyterlab!
  • I still get 2 errors. One is (Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early) and the other is (Module @jupyter-widgets/base, version ^1.2.0 is not registered, however 2.2.0 is)

mChoakumchild avatar Jan 15 '23 00:01 mChoakumchild

My current installed package versions

Package                       Version
----------------------------- --------------------
aiohttp                       3.8.1
aiosignal                     1.2.0
alabaster                     0.7.12
anaconda-client               1.9.0
anaconda-navigator            2.3.2
anaconda-project              0.10.2
anyio                         3.5.0
appdirs                       1.4.4
argon2-cffi                   21.3.0
argon2-cffi-bindings          21.2.0
arrow                         1.2.2
artifacts-keyring             0.3.2
astroid                       2.6.6
astropy                       5.0.4
asttokens                     2.0.5
async-timeout                 4.0.1
atomicwrites                  1.4.0
attrs                         21.4.0
Automat                       20.2.0
autopep8                      1.6.0
azure-common                  1.1.28
azure-core                    1.24.2
azure-cosmosdb-nspkg          2.0.2
azure-cosmosdb-table          1.0.6
azure-nspkg                   3.0.2
azure-storage-blob            12.12.0
Babel                         2.9.1
backcall                      0.2.0
backports.functools-lru-cache 1.6.4
backports.tempfile            1.0
backports.weakref             1.0.post1
bcrypt                        3.2.0
beautifulsoup4                4.11.1
binaryornot                   0.4.4
bitarray                      2.4.1
bkcharts                      0.2
black                         19.10b0
bleach                        4.1.0
bokeh                         2.4.2
boto3                         1.21.32
botocore                      1.24.32
Bottleneck                    1.3.4
brotlipy                      0.7.0
cachetools                    4.2.2
certifi                       2021.10.8
cffi                          1.15.0
chardet                       4.0.0
charset-normalizer            2.0.4
click                         8.0.4
cloudpickle                   2.0.0
clyent                        1.2.2
colorama                      0.4.4
colorcet                      2.0.6
comtypes                      1.1.10
conda                         22.11.1
conda-build                   3.21.8
conda-content-trust           0+unknown
conda-pack                    0.6.0
conda-package-handling        1.8.1
conda-repo-cli                1.0.4
conda-token                   0.3.0
conda-verify                  3.4.2
constantly                    15.1.0
contourpy                     1.0.6
cookiecutter                  1.7.3
cron-descriptor               1.2.30
cryptography                  3.4.8
cssselect                     1.1.0
cycler                        0.11.0
Cython                        0.29.28
cytoolz                       0.11.0
daal4py                       2021.5.0
das-wfc-stash                 0.1.15
dask                          2022.2.1
datashader                    0.13.0
datashape                     0.5.4
debugpy                       1.5.1
decorator                     5.1.1
defusedxml                    0.7.1
diff-match-patch              20200713
distributed                   2022.2.1
docutils                      0.17.1
entrypoints                   0.4
et-xmlfile                    1.1.0
executing                     0.8.3
fastjsonschema                2.15.1
filelock                      3.6.0
flake8                        3.9.2
Flask                         1.1.2
fonttools                     4.25.0
frozenlist                    1.2.0
fsspec                        2022.2.0
future                        0.18.2
gensim                        4.1.2
glob2                         0.7
google-api-core               1.25.1
google-auth                   1.33.0
google-cloud-core             1.7.1
google-cloud-storage          1.31.0
google-crc32c                 1.1.2
google-resumable-media        1.3.1
googleapis-common-protos      1.53.0
greenlet                      1.1.1
grpcio                        1.42.0
h5py                          3.6.0
HeapDict                      1.0.1
holoviews                     1.14.8
hvplot                        0.7.3
hyperlink                     21.0.0
idna                          3.3
imagecodecs                   2021.8.26
imageio                       2.9.0
imagesize                     1.3.0
importlib-metadata            4.11.3
incremental                   21.3.0
inflection                    0.5.1
iniconfig                     1.1.1
intake                        0.6.5
intervaltree                  3.1.0
ipykernel                     6.9.1
ipympl                        0.9.1
ipython                       8.2.0
ipython-genutils              0.2.0
ipywidgets                    7.7.2
isodate                       0.6.1
isort                         5.9.3
itemadapter                   0.3.0
itemloaders                   1.0.4
itsdangerous                  2.0.1
jdcal                         1.4.1
jedi                          0.18.1
Jinja2                        2.11.3
jinja2-time                   0.2.0
jmespath                      0.10.0
joblib                        1.1.0
json5                         0.9.6
jsonschema                    4.4.0
jupyter                       1.0.0
jupyter-client                6.1.12
jupyter-console               6.4.0
jupyter-core                  4.9.2
jupyter-server                1.13.5
jupyterlab                    3.3.2
jupyterlab-pygments           0.1.2
jupyterlab-server             2.10.3
jupyterlab-widgets            1.0.0
keyring                       23.4.0
kiwisolver                    1.3.2
lazy-object-proxy             1.6.0
libarchive-c                  2.9
llvmlite                      0.38.0
locket                        0.2.1
lxml                          4.8.0
Markdown                      3.3.4
MarkupSafe                    2.0.1
matplotlib                    3.6.2
matplotlib-inline             0.1.2
mccabe                        0.6.1
menuinst                      1.4.18
mistune                       0.8.4
mkl-fft                       1.3.1
mkl-random                    1.2.2
mkl-service                   2.4.0
mock                          4.0.3
mpmath                        1.2.1
msgpack                       1.0.2
msrest                        0.7.1
multidict                     5.1.0
multipledispatch              0.6.0
munkres                       1.1.4
mypy-extensions               0.4.3
navigator-updater             0.2.1
nbclassic                     0.3.5
nbclient                      0.5.13
nbconvert                     6.4.4
nbformat                      5.3.0
nest-asyncio                  1.5.5
networkx                      2.7.1
nltk                          3.7
nose                          1.3.7
notebook                      6.4.8
numba                         0.55.1
numexpr                       2.8.1
numpy                         1.21.5
numpydoc                      1.2
oauthlib                      3.2.0
olefile                       0.46
openpyxl                      3.0.9
packaging                     21.3
pandas                        1.4.2
pandocfilters                 1.5.0
panel                         0.13.0
param                         1.12.0
paramiko                      2.8.1
parsel                        1.6.0
parso                         0.8.3
partd                         1.2.0
pathspec                      0.7.0
patsy                         0.5.2
pep8                          1.7.1
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        9.0.1
pip                           21.2.4
pkginfo                       1.8.2
plotly                        5.6.0
pluggy                        1.0.0
poyo                          0.5.0
prometheus-client             0.13.1
prompt-toolkit                3.0.20
Protego                       0.1.16
protobuf                      3.19.1
psutil                        5.8.0
ptyprocess                    0.7.0
pure-eval                     0.2.2
py                            1.11.0
pyarrow                       8.0.0
pyasn1                        0.4.8
pyasn1-modules                0.2.8
pycodestyle                   2.7.0
pycosat                       0.6.3
pycparser                     2.21
pyct                          0.4.6
pycurl                        7.44.1
PyDispatcher                  2.0.5
pydocstyle                    6.1.1
pyerfa                        2.0.0
pyflakes                      2.3.1
Pygments                      2.11.2
PyHamcrest                    2.0.2
PyJWT                         2.1.0
pylint                        2.9.6
pyls-spyder                   0.4.0
PyNaCl                        1.4.0
pyodbc                        4.0.32
pyOpenSSL                     21.0.0
pyparsing                     3.0.4
pyreadline                    2.1
pyrsistent                    0.18.0
PySocks                       1.7.1
pytest                        7.1.1
python-dateutil               2.8.2
python-lsp-black              1.0.0
python-lsp-jsonrpc            1.0.0
python-lsp-server             1.2.4
python-slugify                5.0.2
python-snappy                 0.6.0
pytz                          2021.3
pytz-deprecation-shim         0.1.0.post0
pyviz-comms                   2.0.2
PyWavelets                    1.3.0
pywin32                       302
pywin32-ctypes                0.2.0
pywinpty                      2.0.2
PyYAML                        6.0
pyzmq                         22.3.0
QDarkStyle                    3.0.2
qstylizer                     0.1.10
QtAwesome                     1.0.3
qtconsole                     5.3.0
QtPy                          2.0.1
queuelib                      1.5.0
regex                         2022.3.15
requests                      2.27.1
requests-file                 1.5.1
requests-oauthlib             1.3.1
rope                          0.22.0
rpy2                          3.1.0
rsa                           4.7.2
Rtree                         0.9.7
ruamel.yaml                   0.17.21
ruamel.yaml.clib              0.2.6
ruamel-yaml-conda             0.15.100
s3transfer                    0.5.0
scikit-image                  0.19.2
scikit-learn                  1.0.2
scikit-learn-intelex          2021.20220215.102710
scipy                         1.7.3
Scrapy                        2.6.1
seaborn                       0.11.2
Send2Trash                    1.8.0
service-identity              18.1.0
setuptools                    61.2.0
sgrePolaris                   1.0.31
simplegeneric                 0.8.1
sip                           4.19.13
six                           1.16.0
smart-open                    5.1.0
sniffio                       1.2.0
snowballstemmer               2.2.0
sortedcollections             2.1.0
sortedcontainers              2.4.0
soupsieve                     2.3.1
Sphinx                        4.4.0
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
spyder                        5.1.5
spyder-kernels                2.1.3
SQLAlchemy                    1.4.32
stack-data                    0.2.0
statsmodels                   0.13.2
sympy                         1.10.1
tables                        3.6.1
tabulate                      0.8.9
TBB                           0.2
tblib                         1.7.0
tenacity                      8.0.1
terminado                     0.13.1
testpath                      0.5.0
text-unidecode                1.3
textdistance                  4.2.1
threadpoolctl                 2.2.0
three-merge                   0.1.1
tifffile                      2021.7.2
tinycss                       0.4
tldextract                    3.2.0
toml                          0.10.2
tomli                         1.2.2
toolz                         0.11.2
tornado                       6.1
tqdm                          4.64.0
traitlets                     5.1.1
Twisted                       22.2.0
twisted-iocpsupport           1.0.2
typed-ast                     1.4.3
typing_extensions             4.1.1
tzdata                        2022.4
tzlocal                       4.2
ujson                         5.1.0
Unidecode                     1.2.0
urllib3                       1.26.9
w3lib                         1.21.0
watchdog                      2.1.6
wcwidth                       0.2.5
webencodings                  0.5.1
websocket-client              0.58.0
Werkzeug                      2.0.3
wheel                         0.37.1
widgetsnbextension            3.6.1
win-inet-pton                 1.1.0
win-unicode-console           0.5
wincertstore                  0.2
wrapt                         1.12.1
xarray                        0.20.1
xlrd                          2.0.1
XlsxWriter                    3.0.3
xlwings                       0.24.9
yapf                          0.31.0
yarl                          1.6.3
zict                          2.0.0
zipp                          3.7.0
zope.interface                5.4.0

Keeks77 avatar Jan 20 '23 11:01 Keeks77

Not sure how my jupyter got into this state, but for me what solved this once and for all was:

  1. Stop kernel
  2. jupyter lab build (in same terminal)
  3. Restart kernel
  4. Hard refresh the lab page

Hope this helps someone else!

Gilthans avatar Feb 06 '23 15:02 Gilthans