VS Code Jupyter扩展激活失败:TypeError API不兼容问题求助
VS Code Jupyter扩展激活失败:API不兼容问题解决
问题概述
VS Code版本1.104.3,Jupyter扩展版本2025.8.0,连接虚拟环境内核时界面持续显示“Looking for kernels...”,无法加载可选内核。Jupyter日志报错:
11:08:50.589 [error] Failed to active the Jupyter Extension [TypeError: this.vscNotebook.onDidChangeNotebookCellExecutionState is not a function at new Rk (~/.vscode/extensions/ms-toolsai.jupyter-2023.8.1002501831/out/extension.node.js:24:501992) ...]
核心原因:Jupyter扩展使用了当前VS Code版本不支持的新版Notebook API,导致扩展激活失败、内核检测终止。
已尝试的修复操作:
- 将VS Code更新至1.104.3
- 更新Jupyter、Python扩展至最新版
- 手动清除扩展缓存并重装:
rm -rf ~/.vscode/extensions/ms-toolsai.jupyter-* rm -rf ~/.vscode/extensions/ms-python.python-* - 禁用其他Jupyter相关扩展
- 在虚拟环境安装
ipykernel、jupyter依赖
解决方案
1. 降级Jupyter扩展至兼容版本
VS Code 1.104.3无法支持2025.8.0版本Jupyter扩展的新API,需降级扩展:
- 打开VS Code扩展面板,找到Jupyter扩展
- 点击扩展卡片右上角的齿轮图标,选择「Install Another Version...」
- 选择2024.x系列或更早的稳定版本(如2024.6.0),安装后重启VS Code
2. 升级VS Code至支持新API的版本
若允许升级VS Code,建议更新到1.85及以上版本(该版本开始支持相关Notebook API):
- 打开VS Code的「帮助」-「检查更新」,完成升级后重新安装最新版Jupyter扩展
3. 重新注册虚拟环境内核
确保虚拟环境内核已正确注册到VS Code:
# 激活目标虚拟环境 source your_env/bin/activate # Linux/macOS # 或 your_env\Scripts\activate # Windows # 注册内核 python -m ipykernel install --user --name=your_env_name --display-name="Python (your_env_name)"
执行完成后重启VS Code,重新检测内核。
4. 清理VS Code全局缓存
清理VS Code缓存文件,避免残留配置干扰:
rm -rf ~/.vscode/Cache rm -rf ~/.vscode/CachedData
重启VS Code后重新加载扩展。
内容的提问来源于stack exchange,提问作者Sahil Singhai
相关产品推荐
相关产品推荐

