Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter Lab: Error displaying widget: model not found #255

Closed
tecamenz opened this issue Aug 7, 2020 · 3 comments
Closed

Jupyter Lab: Error displaying widget: model not found #255

tecamenz opened this issue Aug 7, 2020 · 3 comments

Comments

@tecamenz
Copy link

tecamenz commented Aug 7, 2020

Describe the issue

I'm using the Jupyter Lab widget to generate interactive plots. So fare, plotting works nicely. There is only one problem: If I save the notebook, close the kernel and reopen the notebook the next day, all plots are gone and I only see the message "Error displaying widget: model not found". Is this expected behavior?

Versions

ipympl version: 0.5.7
jupyter core     : 4.6.3
jupyter-notebook : 6.1.1
qtconsole        : not installed
ipython          : 7.17.0
ipykernel        : 5.3.4
jupyter client   : 6.1.6
jupyter lab      : 2.2.2
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 5.0.7
traitlets        : 4.3.3
Known nbextensions:
  config dir: C:\Users\Cam\miniconda3\envs\oposad\etc\jupyter\nbconfig
    notebook section
      jupyter-matplotlib/extension enabled
      - Validating: ok
      jupyter-js-widgets/extension enabled
      - Validating: ok
JupyterLab v2.2.2
Known labextensions:
   app dir: C:\Users\Cam\miniconda3\envs\oposad\share\jupyter\lab
        @jupyter-widgets/jupyterlab-manager v2.0.0 enabled  ok
        jupyter-matplotlib v0.7.3 enabled  ok

@zesty
Copy link

zesty commented Aug 7, 2020

EDIT: you do have to run the cell again to re-render the plot 💯 There's a more helpful bit from the plain notebook (localhost:8888/tree) when cold restarting a kernel:

"A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells."

jupyter lab will just give the "model not found" errors (one for the plot, one for the control) and not render the static plot (the plain notebook will render the static image and give the verbose control error)

I've been seeing similar flakiness. I had widgets working a couple days ago in stock defaults conda base env, then I touched it.

Just managed to get a conda env working by installing from that pure defaults base env with:

conda create --name forge
conda activate forge
conda install -c conda-forge jupyterlab ipympl
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib

working testcase:


%matplotlib widget
from ipywidgets import *
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2*np.pi)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
line, = ax.plot(x, np.sin(x))

def update(w = 1.0):
    line.set_ydata(np.sin(w * x))
    fig.canvas.draw_idle()

interact(update);
% jupyter nbextension list 
jupyter labextension list
Known nbextensions:
  config dir: /home/user/anaconda3/envs/forge/etc/jupyter/nbconfig
    notebook section
      jupyter-matplotlib/extension  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
JupyterLab v2.2.4
Known labextensions:
   app dir: /home/user/anaconda3/envs/forge/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        jupyter-matplotlib v0.7.3  enabled  OK
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
argon2-cffi               20.1.0           py37h8f50634_1    conda-forge
attrs                     19.3.0                     py_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.1                      py_0    conda-forge
bleach                    3.1.5              pyh9f0ad1d_0    conda-forge
brotlipy                  0.7.0           py37h8f50634_1000    conda-forge
ca-certificates           2020.6.20            hecda079_0    conda-forge
certifi                   2020.6.20        py37hc8dfbb8_0    conda-forge
cffi                      1.14.1           py37h2b28604_0    conda-forge
chardet                   3.0.4           py37hc8dfbb8_1006    conda-forge
cryptography              3.0              py37hb09aad4_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3             py37hc8dfbb8_1001    conda-forge
freetype                  2.10.2               he06d7ca_0    conda-forge
idna                      2.10               pyh9f0ad1d_0    conda-forge
importlib-metadata        1.7.0            py37hc8dfbb8_0    conda-forge
importlib_metadata        1.7.0                         0    conda-forge
ipykernel                 5.3.4            py37h43977f1_0    conda-forge
ipympl                    0.5.7              pyh9f0ad1d_1    conda-forge
ipython                   5.8.0                    py37_1    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.5.1                      py_0    conda-forge
jinja2                    2.11.2             pyh9f0ad1d_0    conda-forge
jpeg                      9d                   h516909a_0    conda-forge
json5                     0.9.4              pyh9f0ad1d_0    conda-forge
jsonschema                3.2.0            py37hc8dfbb8_1    conda-forge
jupyter_client            6.1.6                      py_0    conda-forge
jupyter_core              4.6.3            py37hc8dfbb8_1    conda-forge
jupyterlab                2.2.4                      py_0    conda-forge
jupyterlab_server         1.2.0                      py_0    conda-forge
kiwisolver                1.2.0            py37h99015e2_0    conda-forge
lcms2                     2.11                 hbd6801e_0    conda-forge
ld_impl_linux-64          2.34                 hc38a660_9    conda-forge
libblas                   3.8.0               17_openblas    conda-forge
libcblas                  3.8.0               17_openblas    conda-forge
libffi                    3.2.1             he1b5a44_1007    conda-forge
libgcc-ng                 9.3.0               h24d8f2e_14    conda-forge
libgfortran-ng            7.5.0               hdf63c60_14    conda-forge
libgomp                   9.3.0               h24d8f2e_14    conda-forge
liblapack                 3.8.0               17_openblas    conda-forge
libopenblas               0.3.10          pthreads_hb3c22a3_4    conda-forge
libpng                    1.6.37               hed695b0_1    conda-forge
libsodium                 1.0.18               h516909a_0    conda-forge
libstdcxx-ng              9.3.0               hdf63c60_14    conda-forge
libtiff                   4.1.0                hc7e4089_6    conda-forge
libwebp-base              1.1.0                h516909a_3    conda-forge
lz4-c                     1.9.2                he1b5a44_1    conda-forge
markupsafe                1.1.1            py37h8f50634_1    conda-forge
matplotlib-base           3.3.0            py37hd478181_1    conda-forge
mistune                   0.8.4           py37h8f50634_1001    conda-forge
nbconvert                 5.6.1            py37hc8dfbb8_1    conda-forge
nbformat                  5.0.7                      py_0    conda-forge
ncurses                   6.2                  he1b5a44_1    conda-forge
notebook                  6.1.1            py37hc8dfbb8_0    conda-forge
numpy                     1.19.1           py37h8960a57_0    conda-forge
olefile                   0.46                       py_0    conda-forge
openssl                   1.1.1g               h516909a_1    conda-forge
packaging                 20.4               pyh9f0ad1d_0    conda-forge
pandoc                    2.10.1               h516909a_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
pexpect                   4.8.0            py37hc8dfbb8_1    conda-forge
pickleshare               0.7.5           py37hc8dfbb8_1001    conda-forge
pillow                    7.2.0            py37h718be6c_1    conda-forge
pip                       20.2.1                     py_0    conda-forge
prometheus_client         0.8.0              pyh9f0ad1d_0    conda-forge
prompt_toolkit            1.0.15                     py_1    conda-forge
ptyprocess                0.6.0                   py_1001    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.6.1                      py_0    conda-forge
pyopenssl                 19.1.0                     py_1    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyrsistent                0.16.0           py37h8f50634_0    conda-forge
pysocks                   1.7.1            py37hc8dfbb8_1    conda-forge
python                    3.7.8           h6f2ec95_1_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.7                     1_cp37m    conda-forge
pyzmq                     19.0.2           py37hac76be4_0    conda-forge
readline                  8.0                  he28a2e2_2    conda-forge
requests                  2.24.0             pyh9f0ad1d_0    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                49.2.1           py37hc8dfbb8_0    conda-forge
simplegeneric             0.8.1                      py_1    conda-forge
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.32.3               hcee41ef_1    conda-forge
terminado                 0.8.3            py37hc8dfbb8_1    conda-forge
testpath                  0.4.4                      py_0    conda-forge
tk                        8.6.10               hed695b0_0    conda-forge
tornado                   6.0.4            py37h8f50634_1    conda-forge
traitlets                 4.3.3            py37hc8dfbb8_1    conda-forge
urllib3                   1.25.10                    py_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_1    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.34.2                     py_1    conda-forge
widgetsnbextension        3.5.1            py37hc8dfbb8_1    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zeromq                    4.3.2                he1b5a44_3    conda-forge
zipp                      3.1.0                      py_0    conda-forge
zlib                      1.2.11            h516909a_1006    conda-forge
zstd                      1.4.5                h6597ccf_2    conda-forge

@tecamenz
Copy link
Author

EDIT: you do have to run the cell again to re-render the plot 💯 There's a more helpful bit from the plain notebook (localhost:8888/tree) when cold restarting a kernel:

"A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells."

jupyter lab will just give the "model not found" errors (one for the plot, one for the control) and not render the static plot (the plain notebook will render the static image and give the verbose control error)

So this is expected behavior and no way the last state of the plots can be saved in the notebook? If so, I think this is an important feature to add don't you think?

@martinRenou
Copy link
Member

Thanks. This is a known issue, closing as duplicate of #16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants