在Jupyter Notebook中,ipywidgets运行良好,但它们似乎在Jupyter Lab中不起作用(据说它比Notebook更好)。
我跟着这些directions。
第1步:安装Node.js(https://nodejs.org/en/)
第2步:使用conda在Python 3上安装了需求:
conda install -c conda-forge ipywidgets
jupyter labextension install @jupyter-widgets/jupyterlab-manager
不幸的是,基本的小部件在jupyter实验室笔记本中不起作用:
JupyterLab现在更喜欢将arbitrary javascript is no longer allowed嵌入到单元格输出中的模型,这是用于工作的交互式Jupyter Notebook模块的数量。他们现在问modules with interactivity create a JupyterLab extension。 IPyWidgets有一个extension that can be activated在你的命令行运行它(假设你已经安装了NodeJS):
jupyter labextension install @jupyter-widgets/jupyterlab-manager
我有相同的pbm,并尝试了这个解决方案(希望它可以帮助其他人):
jupyter labextension install @jupyter-widgets/jupyterlab-manager
在我的案例中给出了这种错误:
> /Users/user/.nvm/versions/node/v8.7.0/bin/npm pack @jupyter-widgets/jupyterlab-manager
jupyter-widgets-jupyterlab-manager-0.35.0.tgz
Errored, use --debug for full output:
ValueError:
"@jupyter-widgets/[email protected]" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab Extension Package
>=0.15.4-0 <0.16.0-0 >=0.16.0-0 <0.17.0-0 @jupyterlab/application
>=1.1.4-0 <2.0.0-0 >=2.0.0-0 <3.0.0-0 @jupyterlab/services
>=0.15.4-0 <0.16.0-0 >=0.16.0-0 <0.17.0-0 @jupyterlab/rendermime
>=0.15.4-0 <0.16.0-0 >=0.16.0-0 <0.17.0-0 @jupyterlab/notebook
然后,我做的是使用以前的版本0.34而不是0.35:jupyter labextension install @jupyter-widgets/[email protected]
事实上,根据this,有时团队有时间考虑最后一个版本。
UP(根据评论):你可以检查jupyter lab --version
并在its version compatibility找到匹配。
它现在有效!
有同样的问题,今天对我有用的是运行'clean'命令,如下所述:https://ipywidgets.readthedocs.io/en/latest/user_install.html#installing-the-jupyterlab-extension
所以:
jupyter lab clean
jupyter labextension install @jupyter-widgets/jupyterlab-manager
这让它刚刚适合我。
我得到了一个Permission Denied
错误,所以将sudo
添加到接受的命令帮助:sudo jupyter labextension install @jupyter-widgets/jupyterlab-manager
。