Jupyter小部件未显示在笔记本中。

7

我正在运行Jupyter笔记本,但是Jupyter小部件没有出现。相反,我收到以下消息:

Failed to display Jupyter Widget of type Button.
If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.
If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.

我有以下版本:

widgetsnbextension (3.0.8)
ipywidgets (7.0.5)

我用以下命令安装了小部件:

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

另外我的代码是:

import ipywidgets as widgets
from IPython.display import display

button = widgets.Button(description='Hello')
display(button)
1个回答

8

我有相同的版本和代码可以正常工作。在启动Jupyter Notebook之前,您是否尝试执行以下操作:

jupyter nbextension enable --py widgetsnbextension --sys-prefix

输出 ==>

Enabling notebook extension jupyter-js-widgets/extension...
         - Validating: ok

**http://ipywidgets.readthedocs.io/en/stable/user_install.html中提供了使用pip进行安装的说明。在使用虚拟环境时,请指定使用此模式。

enter image description here


看起来在问题中,OP放了同样的行,只是没有“--sys-prefix”部分。您是说他们需要包含那个特定的参数,这样就可以解决问题了吗? - Taegost
至少对我来说,添加“--sys-prefix”解决了这个问题。 - Sztyler

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接