You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode指定Jupyter服务器失败报错,如何配置连接Jupyter Lab?

解决VSCode Jupyter扩展连接本地Jupyter Lab服务器的问题

一、修复ImportError: cannot import name 'notebookapp'错误

这个问题通常是notebook包版本过高(7.x及以上)导致的,VSCode Jupyter扩展暂不兼容该版本的API结构,解决步骤:

  • 查看当前notebook版本:
    pip show notebook
    
  • 降级到兼容的6.x稳定版本:
    pip install notebook==6.5.6
    
    执行后重启Jupyter Lab和VSCode。

二、修复command 'jupyter.selectjupyteruri' not found错误

该错误源于命令名称有误或Jupyter扩展未正确安装:

  • 卸载VSCode中的Jupyter扩展,重启VSCode后重新安装最新稳定版;
  • 打开VSCode命令面板(Ctrl+Shift+P / Cmd+Shift+P),输入**Jupyter: Connect to an Existing Jupyter Server**——这是连接现有服务器的正确命令,而非你之前尝试的错误命令。

三、配置VSCode连接已运行的Jupyter Lab服务器

  1. 确认本地Jupyter Lab处于运行状态,从启动终端的输出中找到服务器地址(格式类似http://localhost:8888/lab?token=xxxxxx),记录端口(如8888)和token;
  2. 在VSCode命令面板中执行Jupyter: Connect to an Existing Jupyter Server,输入服务器地址(如http://localhost:8888);
  3. 按提示输入token完成验证,即可连接到已运行的Jupyter Lab服务器。

额外排查:确保VSCode识别正确的Python环境

点击VSCode左下角的Python解释器标识,选择你运行Jupyter Lab的pyenv 3.9.16环境(路径应为~/.pyenv/versions/3.9.16/bin/python),避免因环境不匹配导致的兼容问题。

内容的提问来源于stack exchange,提问作者quickytools

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 00:05:01