欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jupyter notebook中ipywidgets插件不显示

程序员文章站 2022-02-02 09:46:53
...

【环境】mac

【解决】

1,重新安装ipywidgets, widgetsnbextension 。在终端中执行:

pip install --upgrade --force-reinstall ipywidgets
# for windows cmd: pip install --upgrade --force-reinstall ipywidgets --user

pip install --upgrade --force-reinstall widgetsnbextension 
# for windows cmd: pip install --upgrade --force-reinstall widgetsnbextension --user

2,安装jupyter-js-widgets/extension,在终端中执行:

jupyter nbextension install --py widgetsnbextension
# for windows cmd: jupyter nbextension install --py widgetsnbextension --user

# 输出:
'''
Installing C:\Users\Lenovo\AppData\Roaming\Python\Python36\site-packages\widgetsnbextension\static -> jupyter-js-widgets
Making directory: C:\Users\Lenovo\AppData\Roaming\jupyter\nbextensions\jupyter-js-widgets\
Copying: C:\Users\Lenovo\AppData\Roaming\Python\Python36\site-packages\widgetsnbextension\static\extension.js -> C:\Users\Lenovo\AppData\Roaming\jupyter\nbextensions\jupyter-js-widgets\extension.js
Copying: C:\Users\Lenovo\AppData\Roaming\Python\Python36\site-packages\widgetsnbextension\static\extension.js.map -> C:\Users\Lenovo\AppData\Roaming\jupyter\nbextensions\jupyter-js-widgets\extension.js.map
- Validating: ok

    To initialize this nbextension in the browser every time the notebook (or other app) loads:

          jupyter nbextension enable widgetsnbextension --user --py
'''

 

3,在jupyter notebook中开启widgetsnbextension。在终端中执行:

jupyter nbextension enable --py widgetsnbextension --sys-prefix
# for windows cmd: jupyter nbextension enable --py widgetsnbextension --sys-prefix --user

# 输出如下:
# Enabling notebook extension jupyter-js-widgets/extension...
#       - Validating: OK

4,打开jupyter notebook。在终端中执行:

jupyter notebook

5,然后可以运行有widgets内容的代码。

 

【致谢】

landryshuai @ https://github.com/jupyter-widgets/ipywidgets/issues/1146

https://*.com/questions/47396512/jupyter-widget-does-not-appear-in-notebook

http://cn.voidcc.com/question/p-adstwnju-ve.html

https://www.soinside.com/question/ZtKAd9hv5PCjCabNUp6mxA