Tom Horvath
Tom Horvath

Reputation: 31

How to set up Python in VS Code?

I'm new to python (and in coding in general). I'd like to ask some help to set up python on VS Code. I've tried to follow several guides but none of them were really helpful.

The following have been downloaded:

Upvotes: 3

Views: 5873

Answers (2)

TwoUnderscorez
TwoUnderscorez

Reputation: 109

This worked for me:

.vscode/settings.json:

{
    "python.linting.pylintEnabled": false,
    "python.pythonPath": "python.exe"
} 

.vscode/tasks.json:

{
    "version": "2.0.0"
}

.vscode/launch.json:

{
    "version": "2.0.0",
    "configurations": [
        {
            "name": "Python",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "pythonPath": "${config:python.pythonPath}",
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "console": "internalConsole",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        }    
    ]
} 

You can replace "program": "${file}", with "program": "${workspaceRoot}/main.py", to run your main file no matter which file you've selected but I found that that makes errors like syntax errors sometimes not display correctly if at all.

Breaking on exceptions

  1. Press CTRL + SHIFT + D
  2. In the BREAKPOINTS panel, click on Uncaught Exceptions enter image description here

Upvotes: 2

Zroq
Zroq

Reputation: 8392

1) Install VS Code

2) Go to View > Command Palette

3) Type ext install and click on Install Extensions

4) Search for Python and install it

5) Reload VS

6) Start coding

Upvotes: 3

Related Questions