Configure Vs code version 2.0.0 Build Task for python

Viewed 13299

I need help in configuring my Vs code to run scripts in python using Cntrl Shift B, I was working fine until Vs code upgraded to version 2.0.0 now it wants me to configure the Build. And I am clueless what Build is all about.

In the past it worked well when I only needed to configure the task runner. There are youtube videos for the task runner. I cant seem to lay my finger on what the Build is all about.

3 Answers

Here is my configuration for the build (Ctrl+Shift+B)

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "python",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "args": [
                "setup.py",
                "install"
            ],
            "presentation": {
                "echo": true,
                "panel": "shared",
                "focus": true
            }
        }
    ]
}

...Don't have enough reputation to comment on the accepted answer...

At least in my environment (Ubuntu 18.04, w/ virtual env) if arguments are being passed in with "args", the file must be the first argument, as @VladBezden is doing, and not part of the command as @orangeInk is doing. Otherwise I get the message "No such file or directory".

Specifically, the answer @VladBezden has does work for me, where the following does not.

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "${config:python.pythonPath} setup.py", // WRONG, move setup.py to args
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "args": [
                "install"
            ],
            "presentation": {
                "echo": true,
                "panel": "shared",
                "focus": true
            }
        }
    ]
}

This took me a while to figure out, so I thought I would share.

Related