11

I noticed that interactive widgets are not working in my Jupyter Lab notebooks.

The following code should produce an interactive slider but doesn't:

from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets

def f(x):
    return x

interact(f, x=10);

enter image description here

What is the problem here, and how can I get widgets to work?

clstaudt
  • 21,436
  • 45
  • 156
  • 239
  • Possible duplicate of [How to get ipywidgets working in Jupyter Lab?](https://stackoverflow.com/questions/49542417/how-to-get-ipywidgets-working-in-jupyter-lab) – Chrisvdberge Feb 21 '19 at 16:10

2 Answers2

6

You need to install widget extension

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension --sys-prefix
  • `!> jupyter nbextension enable --py widgetsnbextension --sys-prefix 117ms < Tue Oct 2 12:26:48 2018 Error executing Jupyter command 'nbextension': [Errno 2] No such file or directory` – clstaudt Oct 02 '18 at 10:28
  • 2
    This is not fixing it. – Soerendip Jan 29 '20 at 20:47
4

Per the docs:

To install the JupyterLab extension you also need to run the command below in a terminal which requires that you have nodejs installed.

jupyter labextension install @jupyter-widgets/jupyterlab-manager

I think it's the latter nodejs requirement that you are missing e.g. with Conda, first run:

conda install nodejs
ultra909
  • 1,740
  • 1
  • 23
  • 25