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