JupyterLab中用ipysigma+NetworkX遇“model not found”错误求助
问题:JupyterLab中使用ipysigma时出现"Error displaying widget: model not found"
尝试在JupyterLab中结合NetworkX使用ipysigma,先后更换版本、改用Notebook等方案均未解决问题。该错误相关讨论无有效回复,且并非ipysigma专属问题。
复现代码
import networkx as nx from ipysigma import Sigma G = nx.petersen_graph() Sigma(G)
运行后报错:
Error displaying widget: model not found
扩展启用情况
me>jupyter labextension list JupyterLab v4.2.5 C:\Users\me\AppData\Local\anaconda3\envs\my\share\jupyter\labextensions ipysigma v0.24.3 enabled ok (python, ipysigma) jupyter-matplotlib v0.11.4 enabled ok jupyterlab_pygments v0.3.0 enabled ok (python, jupyterlab_pygments) @jupyter-notebook/lab-extension v7.2.2 enabled ok @jupyter-widgets/jupyterlab-manager v3.1.10 enabled X (python, jupyterlab_widgets)
相关包版本
ipykernel 6.29.5 pyh4bbf305_0 conda-forge ipympl 0.9.4 pyhd8ed1ab_0 conda-forge ipysigma 0.24.3 pypi_0 pypi ipython 8.27.0 pyh7428d3b_0 conda-forge ipython_genutils 0.2.0 pyhd8ed1ab_1 conda-forge ipywidgets 7.6.5 pyhd8ed1ab_0 conda-forge jupyter 1.1.1 pyhd8ed1ab_0 conda-forge jupyter-lsp 2.2.5 pyhd8ed1ab_0 conda-forge jupyter_client 8.6.2 pyhd8ed1ab_0 conda-forge jupyter_console 6.6.3 pyhd8ed1ab_0 conda-forge jupyter_core 5.7.2 py312h2e8e312_0 conda-forge jupyter_events 0.10.0 pyhd8ed1ab_0 conda-forge jupyter_server 2.14.2 pyhd8ed1ab_0 conda-forge jupyter_server_terminals 0.5.3 pyhd8ed1ab_0 conda-forge jupyterlab 4.2.5 pyhd8ed1ab_0 conda-forge jupyterlab_pygments 0.3.0 pyhd8ed1ab_1 conda-forge jupyterlab_server 2.27.3 pyhd8ed1ab_0 conda-forge jupyterlab_widgets 1.1.10 pyhd8ed1ab_0 conda-forge
解决方案
从扩展状态可见@jupyter-widgets/jupyterlab-manager标记了X,说明组件加载失败,核心原因是ipywidgets版本与JupyterLab 4.x不兼容(JupyterLab 4要求ipywidgets 8.x,当前版本为7.6.5)。按以下步骤修复:
- 卸载旧版本的widget相关包
pip uninstall ipywidgets jupyterlab_widgets -y
- 安装与JupyterLab 4兼容的版本
pip install ipywidgets==8.1.2 jupyterlab_widgets==3.0.10
- 重建JupyterLab扩展并重启
jupyter lab build jupyter lab clean
完成后关闭当前JupyterLab,重新启动。
- (可选)验证ipysigma兼容性
若上述步骤后仍有问题,尝试升级ipysigma到最新兼容版本:
pip install --upgrade ipysigma
内容的提问来源于stack exchange,提问作者Joe
相关产品推荐
相关产品推荐

