Jupyter Notebook启动失败求助:缺失exemplar参数TypeError问题
解决Jupyter Notebook启动时prometheus-client报错的方案
问题原因
报错TypeError: __new__() missing 1 required positional argument: 'exemplar'是因为prometheus-client 0.17.0版本与当前环境不兼容:该版本的Sample类构造函数新增了必填的exemplar参数,但你使用的notebook 6.4.10版本代码调用时未传递此参数;同时Python 3.6已停止维护,高版本prometheus-client不再适配它。
解决步骤
- 卸载当前的prometheus-client版本
pip uninstall -y prometheus-client
- 安装兼容的旧版本(推荐0.16.0,适配Python3.6和notebook6.4.10)
pip install prometheus-client==0.16.0
- 重新启动Jupyter Notebook
jupyter notebook
备选方案(禁用prometheus监控)
如果不想调整包版本,可以修改Jupyter配置禁用prometheus:
- 生成配置文件(如果没有的话):
jupyter notebook --generate-config
- 打开生成的配置文件(路径会在终端输出),添加以下配置:
c.NotebookApp.prometheus_enabled = False
- 保存后重启Jupyter Notebook
内容的提问来源于stack exchange,提问作者clinewton
相关产品推荐
相关产品推荐

