启动Jupyter服务器时触发AssertionError错误的解决求助
解决Jupyter Notebook启动时的AssertionError问题
方案1:卸载第三方exceptiongroup包
Python 3.10及以上版本内置了exceptiongroup模块,你通过pip安装的第三方exceptiongroup包与系统内置模块冲突,同时和Ubuntu的apport异常钩子不兼容。执行以下命令卸载第三方包:
pip uninstall -y exceptiongroup
完成后重新运行jupyter notebook即可。
方案2:临时绕过断言检查(不推荐长期使用)
若卸载第三方包后问题仍存在,可临时修改exceptiongroup的格式化文件跳过断言:
- 打开文件
/home/username/.local/lib/python3.10/site-packages/exceptiongroup/_formatting.py - 定位到第394行的断言代码:
assert sys.excepthook is apport_python_hook.apport_excepthook - 将该行注释或删除
- 保存文件后重新启动Jupyter Notebook
方案3:使用虚拟环境隔离依赖
为避免系统级Python依赖冲突,建议创建虚拟环境安装Jupyter:
# 创建并激活虚拟环境 python3 -m venv jupyter_env source jupyter_env/bin/activate # 在虚拟环境中安装Jupyter pip install jupyter # 启动Notebook jupyter notebook
内容的提问来源于stack exchange,提问作者Elis Evans
相关产品推荐
相关产品推荐

