How can I overcome "Error: Object 'jupyter.widget' not found in registry"?
Asked Answered
S

3

6

I am running jupyterlab within jupyterhub on kubernetes.

I am trying to display widgets using e.g.

from ipywidgets import interact

@interact(x=(0, 100, 10))
def p(x=50):
    pass

Instead of the intended interactive widget, the lab notebook prints:

interactive(children=(IntSlider(value=50, description='x', step=10), Output()), _dom_classes=('widget-interact...

On inspection of the javascript console:

default.js:129 Error: Object 'jupyter.widget' not found in registry
    at default.js:1474
    at new Promise (<anonymous>)
    at Object.loadObject (default.js:1453)
    at DefaultKernel.<anonymous> (default.js:919)
    at Generator.next (<anonymous>)
    at default.js:9
    at new Promise (<anonymous>)
    at push.YC29.__awaiter (default.js:5)
    at DefaultKernel._handleCommOpen (default.js:911)
    at DefaultKernel.<anonymous> (default.js:1018)

I have tried many different combinations of:

!pip install ipywidgets
!pip install widgetsnbextension --upgrade
!pip install widgetslabextension --upgrade
!conda install -n base -y --override-channels -c main -c conda-forge widgetsnbextension ipywidgets nodejs
!jupyter nbextension enable --py widgetsnbextension
!jupyter labextension enable widgetsnbextension
!jupyter labextension list
!jupyter labextension install @jupyter-widgets/jupyterlab-manager
!jupyter lab clean
!jupyter lab build
!pip install --upgrade Nodejs
!npm install -g npm yarn
!jupyter serverextension enable --py jupyterlab --sys-prefix

jupyterlab is at 1.0.0 and jupyterlab-manager is at 1.0.

Once everything is in order, how do I propagate changes?

NB If I restart jupyterlab the container restarts and all changes are lost.

I will do anything - print versions, pip freeze, run tests, reformat/reword this question.

Does anyone have a remote clue how to resolve this?

Please help!

The following did not help:

How to get ipywidgets working in Jupyter Lab?

https://ipywidgets.readthedocs.io/en/latest/user_install.html#installing-the-jupyterlab-extension

Problem displaying widgets / ipywidgets install unsuccessful

https://github.com/jupyter-widgets/ipywidgets/issues/2220

https://github.com/jupyter-widgets/ipywidgets/issues/2514

https://github.com/jupyter-widgets/ipywidgets/issues/2483

https://github.com/twosigma/beakerx/issues/7520

https://github.com/jupyterlab/jupyterlab/issues/6998

https://jupyterhub.readthedocs.io/en/stable/troubleshooting.html

https://github.com/jupyter-widgets/ipywidgets/issues/1949

https://github.com/jupyter-widgets/ipywidgets/pull/1962

Scrimshaw answered 4/2, 2020 at 12:28 Comment(0)
S
2

Leveraging https://github.com/jupyter-widgets/ipywidgets/issues/2488#issuecomment-509719214, in a jupyterlab terminal - running on jupyterhub - execute:

pythonversion=3.7
labversion=0.34.12
labmanagerversion=0.37.4
ipywidgetsversion=7.4.2

conda install ipywidgets=$ipywidgetsversion -c conda-forge -y --override-channels -c main
conda install jupyterlab=$labversion  -y -c conda-forge --override-channels -c main
jupyter-labextension install @jupyter-widgets/jupyterlab-manager@$labmanagerversion

At this point a jupyter lab clean; jupyter lab build might be of interest.

Then in a .ipynb notebook running in the same jupyterlab window, hit the restart kernel button.

IMPORTANT: Don't forget to also REFRESH the browser page - or all efforts will have been in vain . :\

Then execute the example:

from ipywidgets import interact

@interact(x=(0, 100, 10))
def p(x=50):
    pass

I never thought I would live to see the day but - hey presto - the widget finally appears!

The sad things are that the setup is extremely sensitive to the installation of other extensions and the combination of compatible versions is very specific.

enter image description here

Scrimshaw answered 4/2, 2020 at 14:43 Comment(1)
In the hopes of also getting interact() to work, I tried this from the jupyter/scipy-notebook Docker image and everything broke, with an error in the browser console e.g. ..main.abf319f10d4c4ee43bc1.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff)Modulator
A
0

Since you have tried several potential solutions without success, perhaps it would be wise to explore the possibility that the problem has to do with how JupyterLab and kubernetes are interacting with one another on the back end. If this is the issue, you might need to add your install statement to the underlying container file and rebuild it so that the right extension installs at build time. Are you working with a dockerfile? Do you have the necessary privileges to edit the underlying software container that is being deployed? If no to either of these, is there a system administrator who you can contact?

Aqua answered 4/2, 2020 at 13:17 Comment(0)
D
-1

I'm not on k8s, but in case someone else lands here looking for the same error, the fix for me was to run:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

Restart kernel, reload page, etc.

Deflection answered 5/8, 2020 at 7:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.