在 VScode 任务中使用 conda 环境

问题描述 投票:0回答:1

我有以下内容

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "conda info",
      "type": "shell",
      "command": "type conda; which conda",
    },
    {
      "label": "Activate conda envrionment: mkdocs",
      "type": "shell",
      "command": "conda",
      "args": [
        "activate", "mkdocs"
      ]
    },
    {
      "label": "Serve mkdocs",
      "type": "shell",
      "command": "mkdocs serve --strict --dev-addr localhost:8010",
    },
    {
      "label": "run mkdocs serve in environment",
      "group": "test",
      "presentation": {
        "reveal": "always",
        "panel": "shared"
      },
      "runOptions": { 
        "runOn": "folderOpen" 
      },
      "dependsOrder": "sequence",
      "dependsOn": [
        "conda info",
        "Activate conda envrionment: mkdocs", 
        "Serve mkdocs"
      ],
    }
  ]
}

但是运行任务总是失败,因为

CommandNotFoundError:您的 shell 尚未正确配置为使用“conda activate”。

即使我设置了

"python.condaPath"
并且
conda info
任务显示了正确的路径。 此外,当我在 VScode 中打开终端时,我可以执行命令。

注意,我使用的是 MacOS。

那么如何在任务中使用 conda 环境?

编辑:

为了完整起见,这里是相应的问题https://github.com/microsoft/vscode/issues/167325(已关闭...)

visual-studio-code vscode-tasks
1个回答
0
投票

您找到解决方案了吗? 谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.