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

Mac OS X下VS Code启动Jupyter失败问题求助

问题描述
  • 在Mac OS X系统中,终端激活tf环境后运行jupyter-notebook可正常启动Notebook,能在http://localhost:8888/运行单元格。
  • 但在VS Code中打开.ipynb文件运行单元格时,报错:

    Failed to start Jupyter in the environment 'tf (Python 3.9.15)'. View Jupyter log for further details.

  • 日志核心错误:
    Jupyter command `jupyter-notebook` not found.
    
  • 已安装VS Code的Jupyter相关扩展:Jupyter、Jupyter Keymap、Jupyter Slide Show、Jupyter Cell Tags、Jupyter Notebook Renderers。
  • 此前VS Code运行Notebook正常,安装PDF转换用的TeX扩展后出现问题,重启电脑、更换Conda环境均无法解决。
解决方案
  1. 确认VS Code的Python环境选择
    点击VS Code左下角状态栏的Python版本标识,确认当前选中的是tf (Python 3.9.15)环境,避免环境切换导致的路径错误。

  2. 强制重新安装Jupyter组件
    在系统终端激活tf环境,执行以下命令重装Jupyter和Notebook:

    conda activate tf
    pip install --force-reinstall jupyter notebook
    

    重装后重启VS Code,再次尝试运行Notebook单元格。

  3. 重置VS Code的Jupyter连接配置

    • 按Cmd+Shift+P打开命令面板,输入并执行Jupyter: Reset Jupyter Server Connections,重置Jupyter服务连接。
    • 如果重置无效,打开VS Code的JSON设置(Cmd+Shift+P输入Preferences: Open Settings (JSON)),检查是否存在异常的jupyter配置项,比如jupyter.serverPath,若有则删除该配置,保存后重启VS Code。
  4. 确保VS Code集成终端继承系统环境变量
    在VS Code设置中搜索terminal.integrated.inheritEnv,将其设置为true,让集成终端使用系统终端的环境变量,避免conda环境路径未被识别。设置后在VS Code的集成终端中执行which jupyter-notebook,确认能输出正确的路径。

  5. 排查TeX扩展冲突
    暂时禁用安装的PDF转换TeX扩展,重启VS Code后测试Jupyter是否能正常运行。如果恢复正常,说明两个扩展存在冲突:

    • 更新TeX扩展到最新版本;
    • 查看TeX扩展的文档,调整其配置,避免与Jupyter扩展的环境路径冲突。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 15:10:38