A Jupyter widget could not be displayed because the widget state could not be found.

*一.错误描述:

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.*在jupyter notebook 上运行程序出现以错误

二.错误解释:

无法显示Jupyter窗口小部件,因为找不到窗口小部件状态。 如果存储微件的内核不再可用,或者微件状态未保存在笔记本中,则可能发生这种情况。 您可以通过运行适当的单元格来创建窗口小部件。

三.错误分析和解决办法:

1.系统未安装 widgetsnbextension插件,要想知道系统是否安装了 widgetsnbextension插件,可以用pip search widgetsnbextension检查系统是否安装。具体解决办法如下:

打开anaconda prompt,输入pip search widgetsnbextension,即可查看,如图所示,如果发现未安装,输入pip install widgetsnbextension即可

在这里插入图片描述

2.系统安装的widgetsnbextension插件版本过低,重复以上的步骤,打开anaconda prompt,输入pip search widgetsnbextension,查看版本

版本在这里插入图片描述

如果发现版本过低,则输入pip install ipywidgets==5.0.0或者更高版本,如图所示

在这里插入图片描述