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

VS Code无法识别已安装的本地Python包,请求排查launch.json配置问题

解决VS Code无法识别本地Python包的问题

修正launch.json配置错误

你的launch.json存在两处问题:一是configurations为空,没有配置具体的调试项;二是python.useIsolation和python.defaultInterpreterPath属于VS Code的全局/工作区设置,并非launch.json的合法配置项,放在这里不会生效。

修改后的标准launch.json示例:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "python": "/venv/Scripts/python",
            "justMyCode": false
        }
    ]
}

补充排查步骤

  • 重启Python语言服务:按下Ctrl+Shift+P(Windows/Linux)或Cmd+Shift+P(Mac),输入Python: Restart Language Server执行
  • 验证包的安装路径:在终端运行pip show 你的本地包名,查看Location字段;同时在代码中添加import sys; print(sys.path),确认该路径存在于输出的列表中
  • 检查工作区设置:打开.vscode/settings.json,确保python.defaultInterpreterPath指向你的虚拟环境解释器,且python.analysis.excludePaths未排除本地包所在目录
  • 确认包的安装方式:确保激活虚拟环境后,用pip install -e .(可编辑模式)安装本地包,而非全局pip

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 08:33:18