如何在 vscode 里指定 conda 环境调试 comfyUI

187 阅读1分钟

关键点

  1. 在 vscode 安装 python extension

  2. 需要在 .vscode/launch.json 指定 conda 的环境

细节

安装 vscode python 插件

在项目环境中设置 debug 配置

在项目环境创建 .vscode/launch.json 内容如下

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "ComfyUI Debug",
      "type": "debugpy",
      "pythonPath": "/Users/xxx/anaconda3/envs/comfyui/bin/python",
      "request": "launch",
      "program": "main.py",
      "console": "integratedTerminal",
      "args": []
    }
  ]
}

注意 pythonPath 这个值需要指定为 conda 中 python 地址,查找方式执行 conda env list

base                  *  /Users/xxx/anaconda3
comfyui                  /Users/xxx/anaconda3/envs/comfyui
ml                       /Users/xxx/anaconda3/envs/ml

/Users/xxx/anaconda3/envs/comfyui/bin/python 就是你指定的 python

执行

设置断点,点击 Debug 按钮就可以调试了

其他

如果启动有参数,可以通过 launch.json 的 args 来传递