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

VS Code内核启动失败提示缺少prompt_toolkit.formatted_text模块的解决方法

解决VS Code Jupyter内核启动提示缺少prompt_toolkit.formatted_text的问题
  • 确认VS Code关联的Python解释器是安装了prompt_toolkit的Anaconda环境

    • 点击VS Code左下角的Python版本号,选择目标Anaconda环境;或者按Ctrl+Shift+P,输入Python: Select Interpreter选中对应环境
  • 在VS Code终端中重新安装/修复prompt_toolkit

    1. 打开VS Code终端(Ctrl+``),确保终端已激活目标Anaconda环境(自定义环境需先运行conda activate 环境名`)
    2. 执行命令强制重新安装:conda install -c conda-forge prompt_toolkit --force-reinstall
    3. 或者用pip升级:pip install --upgrade prompt_toolkit
  • 验证模块是否正常可用
    在VS Code的Python交互终端中输入以下代码,确认无报错:

    import prompt_toolkit
    print(prompt_toolkit.__version__)
    from prompt_toolkit.formatted_text import FormattedText
    

    若执行正常,重启VS Code和Jupyter内核尝试

  • 重置Jupyter内核配置

    • 按Ctrl+Shift+P,输入Jupyter: Reset Kernels,选择重置所有内核
    • 或者删除Anaconda环境对应的.jupyter配置文件夹(Windows路径为C:\Users\你的用户名\.jupyter,Linux/macOS为~/.jupyter),备份后删除,再重启内核

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.24 19:52:09