今天安装NGLview, 用Notebook打开运行, 理论上会显示Canvas结果 (实际是Widget), 但显示出一行字:
A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells.
google搜不到啥有意义的东东.. 总之意思是小部件无法显示, 因为部件没有配置加载好.
打开nbextensions的配置器, 里面显示jupyter-js-widgets
和nglview-js-widgets
插件前面是警告⚠️状态.
在配置器上方有一个可选性, 显示:
disable configuration for nbextensions without explicit compatibility (they may break your notebook environment, but can be useful to show for nbextension development)
取消以后, 这两个插件就可以勾选了, 而不是之前的无法选取状态. 但他们依旧颜色高亮, 选择以后, 显示:
This nbextension is enabled in the notebook json config, but doesn't provide a yaml file to tell us how to configure it. You can still enable or disable it from here, though.
意思是, 插件虽然打开了, 但不能提供yaml
文件来告诉nbextension怎么配置它.
实际上, 不用管这个的, 就算无yaml文件, 勾选后这个依然能正常运行. (安装jupyter_nbextensions_configurator
就会出现上述问题, 帮你把jupyter-js-widgets
给禁了..
现在应该问题就解决了. 如果不行, 检查该插件是否正常打开(实际检查widgetsnbextension
, 这个就包含了jupyter-js-widgets
.)
## 开启 widgetsnbextension
jupyter nbextension enable --py --sys-prefix widgetsnbextension
## 如果显示OK, 没有报错, 那就去github issue问题吧.
如果还不行, 查看一下nbextensions文件夹是否已经含有插件,
## 列出Jupyter的config路径, data路径和runtime路径
jupyter --path
运行结果可能是:
config:
/Users/hom/.jupyter
/Users/hom/anaconda3/etc/jupyter
/usr/local/etc/jupyter
/etc/jupyter
data:
/Users/hom/Library/Jupyter
/Users/hom/anaconda3/share/jupyter
/usr/local/share/jupyter
/usr/share/jupyter
runtime:
/Users/hom/Library/Jupyter/runtime
在data
所述的文件夹中, 找一下nbextensions
这文件夹, 一般在/Users/hom/anaconda3/share/jupyter
中, 如果有用户配置, 可能会在/Users/hom/Library/Jupyter
(这里hom是用户名, MacOS系统).
网友评论