Jupyter Notebook javascript error when trying to display the widgets
在尝试显示Jupyter Notebook中的小部件时遇到JavaScript错误
题意:在尝试显示Jupyter Notebook中的小部件时遇到JavaScript错误
问题背景:
I am currently working on a EDA Project using ydata_profiling
library.
用户正在进行一个使用 `ydata_profiling` 库的EDA项目。
This is the code i have written as of now:
这是我目前编写的代码:
import numpy as np
import pandas as pd
from ydata_profiling import ProfileReport
profile = ProfileReport(df, title='Pandas Profiling Report', explorative=True)
profile.to_widgets()
On displaying this .to_widgets()
code, a summary of my data appears, but under the variables section i get this javascript error:
在显示这个`.to_widgets()`代码时,数据的摘要会出现,但在“变量”部分我得到这个JavaScript错误:
[Open Browser Console for more detailed log - Double click to close this message]
Model class 'AccordionModel' from module '@jupyter-widgets/controls' is loaded but can not be instantiated
Error: widget model not found
at f.get_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:3460)
at P (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/595.998263bfa9875eeeb29b.js?v=998263bfa9875eeeb29b:1:6289)
at Object.P [as deserialize] (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/595.998263bfa9875eeeb29b.js?v=998263bfa9875eeeb29b:1:6099)
at kt._deserialize_state (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/595.998263bfa9875eeeb29b.js?v=998263bfa9875eeeb29b:1:12378)
at f._make_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:7932)
Report generated by YData.
I would really appreciate some suggestions or fixes for this.
我非常感激能收到一些建议或解决方法。
Solution: Please don't overlook updating the version of your jupyter notebook. I updated the entire jupyter notebook environment and reloaded and issue got resolved. Run commands like :
解决方案:请不要忽视更新Jupyter Notebook的版本。我更新了整个Jupyter Notebook环境并重新加载,问题就解决了。运行如下命令:
jupyter notebook --version
pip install --upgrade notebook
问题解决:
Jupyter Lab issue displaying widgets (javascript error) received several relevant answers, none of them being a definite answer on its own. This suggests:
收到了一些相关的答案,但没有一个是明确的答案。这表明:
- that you should update ipywidgets because some versions have been reported to cause this issue, e.g. 7.7.2 (this answer: 你应该更新ipywidgets,因为有些版本被报告会导致这个问题,例如7.7.2(这个答案: https://stackoverflow.com/a/73733358/12846804)
- that this might also arise from outdated jupyter notebook version, as some versions require manual activation of widgets (this answer: 这也可能是由于Jupyter Notebook版本过旧所导致的,因为某些版本需要手动激活小部件(这个答案: https://stackoverflow.com/a/76946167/12846804)
So, first step is making sure the whole environment is up to date, starting with conda, then Jupyter and ipywidgets.
所以,第一步是确保整个环境是最新的,从conda开始,然后是Jupyter和ipywidgets。
A couple notes: 几点说明:
- Caution: Because you are using conda, do stick to conda and not mix in some pip commands, because those are not going to install things at the same location, so you're asking for trouble. 注意:因为你使用的是conda,请坚持使用conda,不要混合使用pip命令,因为pip安装的东西和conda安装的位置不同,这样可能会导致问题。
- Since you're updating, consider making the move from Jupyter to JupyterLab. 既然你在更新,考虑将Jupyter从Jupyter Notebook迁移到JupyterLab。
更多推荐
所有评论(0)