TLJH环境中使用ipysheet遇SheetModel加载失败问题求助
TLJH非base环境中ipysheet无法渲染表格,报SheetModel加载失败错误
问题描述
在TLJH 3.6.1版本的非base conda虚拟环境中,运行JupyterLab或经典Jupyter Notebook时执行以下代码:
from ipysheet import sheet sheet(rows=1, columns=4)
出现JavaScript错误,无法渲染预期的表格。本地无JupyterHub的Miniconda环境中相同代码可正常运行,已将TLJH环境依赖版本降至与本地一致,但问题仍存在。
错误提示
[Open Browser Console for more detailed log - Double click to close this message] Failed to load model class 'SheetModel' from module 'ipysheet'
完整浏览器控制台错误日志:
[Open Browser Console for more detailed log - Double click to close this message] Failed to load model class 'SheetModel' from module 'ipysheet' loadClass@http://0.0.0.0:12000/user/admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js?v=40eaa5b8e976096d50b2:1:74856 loadModelClass@http://0.0.0.0:12000/user/admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:10729 _make_model@http://0.0.0.0:12000/user/admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:7517 new_model@http://0.0.0.0:12000/user/admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:5137 handle_comm_open@http://0.0.0.0:12000/user/admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:3894 134/v/this._handleCommOpen@http://0.0.0.0:12000/user/admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js?v=40eaa5b8e976096d50b2:1:73393 _handleCommOpen@http://0.0.0.0:12000/user/admin/static/lab/jlab_core.3e11c5239452d671150c.js?v=3e11c5239452d671150c:2:1037310
环境信息
- TLJH部署环境:Ubuntu 20.04.5 LTS Docker容器
- 本地正常环境:Ubuntu 22.04.1 LTS主机Miniconda(无JupyterHub)
- 测试使用同一浏览器
- TLJH非base环境依赖版本:
:~$ conda list | grep ipy ipykernel 6.19.2 pyh210e3f2_0 conda-forge ipysheet 0.7.0 pyhd8ed1ab_0 conda-forge ipython 8.10.0 pyh41d4057_0 conda-forge ipywidgets 8.0.4 pyhd8ed1ab_0 conda-forge :~$ conda list | grep jupy jupyter_client 8.1.0 pyhd8ed1ab_0 conda-forge jupyter_core 5.3.0 py311h38be061_0 conda-forge jupyterlab_widgets 3.0.5 pyhd8ed1ab_0 conda-forge
已将TLJH环境依赖版本与本地对齐,升级ipywidgets至8.0.4后问题仍未解决。
解决方案
1. 重装ipysheet并重建JupyterLab扩展
切换到目标非base环境,执行以下命令:
conda uninstall -y ipysheet conda install -y ipysheet=0.7.0 # 确保安装nodejs(JupyterLab build依赖) conda install -y nodejs jupyter lab build
2. 检查并确认Jupyter扩展状态
执行命令查看已安装的JupyterLab扩展:
jupyter labextension list
需确保@jupyter-widgets/jupyterlab-manager和ipysheet扩展处于启用状态。若未找到ipysheet扩展,手动安装:
jupyter labextension install ipysheet
3. 清理JupyterLab缓存
先清除浏览器缓存,再执行以下命令清理JupyterLab本地缓存并重建:
jupyter lab clean jupyter lab build
4. 验证虚拟环境kernel关联正确性
检查当前可用的kernel列表:
jupyter kernelspec list
确认目标非base环境的kernel已注册,若未注册则重新安装ipykernel并注册:
conda install -y ipykernel=6.19.2 python -m ipykernel install --user --name <你的环境名称> --display-name "<Jupyter中显示的名称>"
5. 检查TLJH环境隔离配置
确保TLJH正确加载目标非base环境的扩展,可设置该环境为默认用户环境:
sudo tljh-config set user_environment.default <你的环境名称> sudo tljh-config reload
内容的提问来源于stack exchange,提问作者lonfo
相关产品推荐
相关产品推荐

