VS Code task and Python virtual environment

后端 未结 3 1570
一生所求
一生所求 2020-12-20 13:11

I have a python virtual environment declared in my workspace settings, everything is fine with it.

Now I have a build task that calls a make target whic

3条回答
  •  礼貌的吻别
    2020-12-20 13:46

    I'm late to the party, but this alternative might be useful. If you use pipenv in stead of standard venv, you can use pipenv run. It will activate the virtualenv before running the process. For example, this works for building sphinx:

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "build html",
                "type": "process",
                "command": "pipenv",
                "args": [
                    "run", 
                    "sphinx-build", 
                    "-b", 
                    "html", 
                    "${workspaceFolder}", 
                    "${workspaceFolder}/_build/html"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                },
                "presentation": {
                    "reveal": "always",
                    "panel": "new"
                }
            }
        ]
    }
    

提交回复
热议问题