2017-05-03 380 views
4

問題: 我在MacOs 10.9中安裝了python3和jupyter筆記本,使用pip3。
當我嘗試運行這個小部件時,它給出了沒有javascript小部件的錯誤。 我在Jupyter筆記本中安裝了python3和R內核。Jupyter notebook:Widget Javascript未檢測到

代碼:

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?

+0

在這裏找到答案(壞消息 - ipywidgets不PyCharm支持): https://stackoverflow.com/questions/41106767/pycharm-notebook- widget-javascript-not-detected –

回答

2

運行以下命令: jupyter nbextension enable --py --sys-prefix widgetsnbextension,然後在Jupyter中重新啓動內核應該這樣做。

+2

啓用筆記本擴展是SUCCESSFUL,但是,但是,模塊小部件仍然給出錯誤:未檢測到Widget Javascript。它可能沒有正確安裝或啓用。我們是否也可以解決WIDGETS問題? –

+0

你不只是錯過了ipywidgets?嘗試通過運行安裝它:pip安裝ipywidgets – chjortlund

+0

不適用於我。我仍然得到相同的錯誤 – Alex

0

我面臨同樣的問題,在運行命令後:jupyter nbextension enable --py --sys-prefix widgetsnbextension,應該會出現提示:

>Enabling notebook extension jupyter-js-widgets/extension... 

- Validating: ok。 刷新你的jupyter筆記本和小工具的工作。

2

我用Jupyter,Mac OS,Python 3.6和Anaconda成功地使用了以下命令。第一個命令此時獲取最新版本的ipywidgets(版本7.0)。

conda install -c conda-forge ipywidgets 

jupyter nbextension enable --py widgetsnbextension 
+1

事實上,'ipywidgets'的conda-forge版本更新,這解決了我的情況。 – dcatteeu

-2

可能是最好的方式,至少它對我有效:重新安裝ipywidgets和widgetsextension它應該工作。

pip uninstall ipywidgets widgetsnbextension 

pip install ipywidgets 

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

這解決了這個問題對我來說:

jupyter labextension install @jupyter-widgets/jupyterlab-manager