This happens because the code is run through the Terminal.
In short, under the hood, VSCode opens a new terminal and executes the command to run your program using the full path. It's done this way to avoid possible conflicts, if you choose to e.g. use an external terminal with a custom configuration.
VSCode can also display the program output only, via the Debug Console (tab to the left from Terminal). To do this, you need to create a custom launch configuration.
In the Run and Debug tab click create a launch.json file (if you don't have one already) and select the Python File template. Then, in .vscode/launch.json change property "console": "integratedTerminal", to "console": "internalConsole" for the desired configuration. See the complete config below:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole",
"justMyCode": true
}
]
}
With this in place, you can run your Python file like before, and see the program output in the Debug Console:
