view raw
tomab tomab - 8 months ago 71
Python Question

VSCode doesn't show python script error output

Using Python3 with Visual Studio Code (Python extension installed) within Ubuntu 16.04.
I have some basic script written:

def mainMethod():


if __name__ == "__main__":

When I debug this in Visual Studio Code by hitting F5 I can't see any output with the error in Debug Console:

Traceback (most recent call last):
File "", line 9, in
File "", line 5, in mainMethod

NameError: name 'what' is not defined

If I run
in console the output appears.

How can I see those errors in VSCode and avoid switching back and forth between it and console?


I still can't see the output in Debug Console all the time but I can see it in the Integrated Terminal by setting this option in launch.json file of VSCode. The file looks like this:

"version": "0.2.0",
"configurations": [
        "name": "Python virtual env",
        "type": "python",
        "request": "launch",
        "stopOnEntry": false,
        "console": "integratedTerminal",
        "program": "${workspaceRoot}/",
        "debugOptions": [
        "pythonPath": "${workspaceRoot}/env/bin/python3"

The core line is "console": "integratedTerminal". Also please note that this configuration is using the interpreter from the Virtual Environment folder and the file which starts is always instead of the default option which runs the file from the active editor.