VS Code starts debugging in integrated terminal in

2020-01-30 12:06发布

问题:

I've been using VS Code for quite some time and just today I started having this strange issue. Previously if I started debugging an program (F5) it would start debugging and show output in the "Debug Console":

But now It starts debugger in the "Terminal" and also outputs to "Debug Console".

Here is my launch.json:

{
    "version": "0.2.0",
    "configurations": [{
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}"
        }
    ]
}


I want output only in the "Debug Console" (previously default behavior). Please help me with setting it back to the way it was.

回答1:

Edit 3

As with the release 2019.4.0 of the python extension it is now possible to set the console option to internalConsole (#4321).

Edit 2

As suggested in omartin2010's answer you can additionally set the option

"internalConsoleOptions": "openOnSessionStart"

to automatically open the debug console when starting debugging.

Edit 1

Setting the console option explicitly to none was the way to go. See comments.

"console": "none"

Original answer

To ensure that the output is written to the debug console you can set the debugOptions. Adding the following entry to your configuration in yourlaunch.json should fix it:

"debugOptions": [
    "RedirectOutput"
]


回答2:

I had the same problem but I solved it by adding a new configuration at the top that looked like this:

{
    "name": "Python: Current File",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "console": "none"
},

I found this a better solution because I didn't have to change one of my other debug functions. In your case the "Python: Terminal (integrated)" debug option. Which I need as much as I need the debug console function. I use both function and they show the output where I want the output to be shown.



回答3:

The preferred answer above of setting

    "console": "none" 

now throws an error.

The new usage is

    "console": "internalConsole"

There's a bug logged in GitHub to update the docs here.



回答4:

{
    "name": "Python: Current File",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "stopOnEntry": false,
    "console": "none"
},

these are my launch.json settings and it's working with this.



回答5:

It's also possible, as of I guess not too long ago, to add this option... not sure it was possible before:

{
...
            "internalConsoleOptions": "openOnSessionStart",
...
}

hope this helps



回答6:

The accepted answer didn't work for me as it doesn't appear to be an option on my version of VSCode Version 1.30.2 (1.30.2):

Unknown console type 'none'.

The solution for me was to use the internalConsole option instead. I suppose it must be defaulting to the integratedTerminal option on my version.

Here is an example:

NOTE: this is an example from my nodejs project but the console portion is still relevant regardless of project type. I have included more to show some context as well as other features such as envFile usage.

...    
{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "envFile": "${workspaceRoot}/.env",
    "program": "${workspaceFolder}/src/index.js",
    "autoAttachChildProcesses": true,
    "console": "internalConsole"
},
...


回答7:

From the above answers, the one worked for me was changing the value of the "console" key with "internalConsole" as below:

 "configurations": [
    {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "internalConsole"
    },