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);
What is the problem here, and how can I get widgets to work?
You need to install widget extension
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension --sys-prefix
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 eg with Conda, first run:
conda install nodejs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.