How to get ipywidgets working in Jupyter Lab?

user5601 picture user5601 · Mar 28, 2018 · Viewed 32.7k times · Source

In Jupyter Notebook, ipywidgets work fine, however they seem to not work in Jupyter Lab (which is supposedly better than Notebook).

I followed these directions.

Step 1: Installed Node.js (https://nodejs.org/en/)

Step 2: Installed requirements on Python 3 with conda:

conda install -c conda-forge ipywidgets
jupyter labextension install @jupyter-widgets/jupyterlab-manager

Unfortunately, basic widgets do not work inside the jupyter lab notebook:

enter image description here

Answer

scnerd picture scnerd · Apr 2, 2018

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 has an extension that can be activated by running this on your command line (which assumes you already have NodeJS installed):

jupyter labextension install @jupyter-widgets/jupyterlab-manager