How to get ipywidgets working in Jupyter Lab?

I had the same pbm, and tried this solution (hope it can help others):

The jupyter labextension install @jupyter-widgets/jupyterlab-manager gave this kind of error in my case:

> /Users/user/.nvm/versions/node/v8.7.0/bin/npm pack @jupyter-widgets/jupyterlab-manager
jupyter-widgets-jupyterlab-manager-0.35.0.tgz

Errored, use --debug for full output:
ValueError:
"@jupyter-widgets/[email protected]" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab              Extension            Package
>=0.15.4-0 <0.16.0-0    >=0.16.0-0 <0.17.0-0 @jupyterlab/application
>=1.1.4-0 <2.0.0-0      >=2.0.0-0 <3.0.0-0   @jupyterlab/services
>=0.15.4-0 <0.16.0-0    >=0.16.0-0 <0.17.0-0 @jupyterlab/rendermime
>=0.15.4-0 <0.16.0-0    >=0.16.0-0 <0.17.0-0 @jupyterlab/notebook

Then, what I did is to use a previous version 0.34 instead of 0.35: jupyter labextension install @jupyter-widgets/[email protected]

In fact, according to this, sometime teams get time to consider the last version.

UP (according to comments): You can check jupyter lab --version and find match on its version compatibility.

And it works now !

enter image description here


JupyterLab now prefers a model where arbitrary javascript is no longer allowed to be embedded in a cell's output, which is how many interactive Jupyter Notebook modules used to work. They now ask that modules with interactivity create a JupyterLab extension. ipywidgets provides @jupyter-widgets/jupyterlab-manager extension which satisfies this requirement.

When using ipywidgets 7.6 or newer in JupyterLab 3.0 or newer you do not need to do anything: it is installed by default. You can check if this is installed by running:

jupyter labextension list

which should include a line like:

@jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)

If you are using JupyterLab 1 or 2 (or old version of ipywidgets) you need to install this extension manually by running this on your command line (which assumes you already have NodeJS installed):

jupyter labextension install @jupyter-widgets/jupyterlab-manager