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?

asked Oct 1, 2018 at 11:39
1

4 Answers 4

6

You need to install widget extension

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension --sys-prefix
answered Oct 1, 2018 at 17:01
Sign up to request clarification or add additional context in comments.

2 Comments

!> 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
This is not fixing it.
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
answered Apr 1, 2019 at 8:35

1 Comment

Didn't work for me - Error: Object 'jupyter.widget' not found in registry
0

This works for me:

delete all output cells

save notebook

reload page

restart kernel

run with %matplotlib widget

answered Jan 4, 2024 at 23:03

1 Comment

This is an old post you've now tagged with a more current answer. (ipywidgets no long needs nodejs or a separate command to trigger the extension to be useful in current Jupyter.) Thanks. I'm a bit unsure though if %matplotlib widget is really needed though? As discussed here that is related to using interactive plots with ipympl. I don't see why ipywidgets would need a magic command that set the matplotlib backend?
0

When using Anaconda

  • open Anaconda.Navigator
  • open Environments from the left Navigation panel
  • select base(root) (base root is fine for testing, not for production!)
  • search for: "nbex"

for whatever reasons the package widgetsnbextension is not pre-installed.

  • tick the box left to the package and "Apply"
  • make sure the base (root) environment is selected
  • start Jupyterlab

the widgets should work now

answered May 30, 2024 at 14:10

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.