Interactive Jupyter Widgets not working in Jupyter Lab

早过忘川 提交于 2020-12-25 09:49:12

问题


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?


回答1:


You need to install widget extension

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension --sys-prefix



回答2:


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


来源:https://stackoverflow.com/questions/52590291/interactive-jupyter-widgets-not-working-in-jupyter-lab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!