Jupyter 笔记本:未检测到小部件 Javascript
Jupyter notebook: Widget Javascript not detected
问题:
我在 MacOs 10.9 中使用 pip3 安装了 python3 和 jupyter notebook。
当我尝试 运行 小部件时,它给出了没有 javascript 小部件的错误。
我在 Jupyter-notebook 中安装了 python3 和 R 内核。
代码:
from ipywidgets import widgets
from IPython.display import display
text = widgets.Text()
display(text)
text.on_submit('hello')
错误:
Widget Javascript not detected. It may not be installed or enabled properly.
尝试次数:
sudo -H pip3 install ipywidgets
sudo -H pip3 install -upgrade ipywidgets
jupyter nbextension enable --py widgetsnbextension
# restarted the computer.
最后一条命令出错。
[EnableNBExtensionApp] CRITICAL | Bad config encountered during initialization:
[EnableNBExtensionApp] CRITICAL | Unrecognized flag: '--py'
请注意,在 mac 中我有 jupyter-nbextension 命令,但是命令:
jupyter-nbextension enable --py widgetsnbextension
也不行。
但是jupyter nbextension enable widgetsnbextension
没有报错,也没有做任何事情。如果我 运行 代码,则会弹出相同的错误。
此外,
import ipywidgets
ipywidgets.__version__
给出“6.0.0”。
一些注意事项:
which jupyter
jupyter is /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter
which jupyter-notebook
jupyter-notebook is /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter-notebook
相关链接:
https://github.com/jupyter-widgets/ipywidgets/issues/541
https://github.com/jupyter/help/issues/32
https://github.com/jupyter/help/issues/131
https://github.com/binder-project/binder/issues/83
如何安装小部件?
我需要单独安装 java 吗?
运行 以下命令:
jupyter nbextension enable --py --sys-prefix widgetsnbextension
,然后在 Jupyter 中重启内核应该可以解决问题。
我遇到了同样的问题,在 运行 命令:jupyter nbextension enable --py --sys-prefix widgetsnbextension
之后,应该会出现提示:
>Enabling notebook extension jupyter-js-widgets/extension...
- Validating: ok
。
刷新您的 jupyter notebook,小部件工作正常。
我在 Jupyter、Mac OS、Python 3.6 和 Anaconda 中成功使用了以下命令。第一条命令获取此时最新版本的ipywidgets(7.0版本)。
conda install -c conda-forge ipywidgets
jupyter nbextension enable --py widgetsnbextension
可能是最好的方法,至少它对我有用:重新安装 ipywidgets 和 widgetsextension,它应该可以工作。
pip uninstall ipywidgets widgetsnbextension
pip install ipywidgets
jupyter nbextension enable --py --sys-prefix widgetsnbextension
这为我解决了:
jupyter labextension install @jupyter-widgets/jupyterlab-manager
问题:
我在 MacOs 10.9 中使用 pip3 安装了 python3 和 jupyter notebook。
当我尝试 运行 小部件时,它给出了没有 javascript 小部件的错误。
我在 Jupyter-notebook 中安装了 python3 和 R 内核。
代码:
from ipywidgets import widgets
from IPython.display import display
text = widgets.Text()
display(text)
text.on_submit('hello')
错误:
Widget Javascript not detected. It may not be installed or enabled properly.
尝试次数:
sudo -H pip3 install ipywidgets
sudo -H pip3 install -upgrade ipywidgets
jupyter nbextension enable --py widgetsnbextension
# restarted the computer.
最后一条命令出错。
[EnableNBExtensionApp] CRITICAL | Bad config encountered during initialization:
[EnableNBExtensionApp] CRITICAL | Unrecognized flag: '--py'
请注意,在 mac 中我有 jupyter-nbextension 命令,但是命令:
jupyter-nbextension enable --py widgetsnbextension
也不行。
但是jupyter nbextension enable widgetsnbextension
没有报错,也没有做任何事情。如果我 运行 代码,则会弹出相同的错误。
此外,
import ipywidgets
ipywidgets.__version__
给出“6.0.0”。
一些注意事项:
which jupyter
jupyter is /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter
which jupyter-notebook
jupyter-notebook is /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter-notebook
相关链接:
https://github.com/jupyter-widgets/ipywidgets/issues/541
https://github.com/jupyter/help/issues/32
https://github.com/jupyter/help/issues/131
https://github.com/binder-project/binder/issues/83
如何安装小部件?
我需要单独安装 java 吗?
运行 以下命令:
jupyter nbextension enable --py --sys-prefix widgetsnbextension
,然后在 Jupyter 中重启内核应该可以解决问题。
我遇到了同样的问题,在 运行 命令:jupyter nbextension enable --py --sys-prefix widgetsnbextension
之后,应该会出现提示:
>Enabling notebook extension jupyter-js-widgets/extension...
- Validating: ok
。
刷新您的 jupyter notebook,小部件工作正常。
我在 Jupyter、Mac OS、Python 3.6 和 Anaconda 中成功使用了以下命令。第一条命令获取此时最新版本的ipywidgets(7.0版本)。
conda install -c conda-forge ipywidgets
jupyter nbextension enable --py widgetsnbextension
可能是最好的方法,至少它对我有用:重新安装 ipywidgets 和 widgetsextension,它应该可以工作。
pip uninstall ipywidgets widgetsnbextension
pip install ipywidgets
jupyter nbextension enable --py --sys-prefix widgetsnbextension
这为我解决了:
jupyter labextension install @jupyter-widgets/jupyterlab-manager