0

In VS Code, when running a python program via the debugger, with launch.json, and console setting set to "internalConsole", then I can't receive input from the command line. I'm not sure if it's supposed to be like that, and thus if that's just a limitation of that setting?

By the way, i'm talking about when clicking the green play button, not the little white play button in the top right. And not the big white play button on the far left sidebar/ in the activity bar{1}. (I see that the big white one brings up the green one. And I see that the little white one isn't associated with the debugger. And the little green one is for the debugger 'cos when I have a breakpoint it stops on the breakpoints when I use the little green one). So hence i'm talking about when clicking the little green one.

enter image description here

I have found that I don't need to use launch.json, and i've found that if using launch.json then i'm fine with the default setting for console, of IntegratedTerminal, but that aside, suppose I do use launch.json, and with the "internalConsole" setting.

Note- I have at times gotten a timeout error when using the default option of IntegratedTerminal which I resolved with one of the answers here Visual Studio Code Python Timeout waiting for debugger connection by using the InternalConsole setting. Right now i'm not getting a timeout error with IntegratedTerminal, and i'm asking about InternalConsole setting in this question.

in VS Code, does the launch.json setting of console: "internalConsole" make it impossible to get input from the console? (error of EOFError )

enter image description here

The above is my question

I'll just expand a bit on the process I did to create the project.

I see that when no folder is open then when clicking the big white button with the insect on it, it mentions about creating a folder. And when creating a folder/directory, it gives a link to create a launch.json file. So I made a directory/folder and opened it in VS Code and in that bar on the far left, the "activity bar" {1} I clicked the big white play button with a pic of an insect crawling up it, to bring up more options, and I chose "create a launch.json file".

enter image description here

I see that the launch.json file has a setting for "console", and that setting, has these three possible values. "integratedTerminal" and "externalTerminal" and "internalConsole". And i've seen that "integratedTerminal" is the default.

enter image description here

When I try running the program via the debugger, so, using VS Code's green play button, then the input line fails. whether input() or raw_input()(what python 2.7 uses).

If I run it manually from the terminal within VS Code(and uncomment the input line!), then it's fine. It lets me input whatever.

enter image description here

But if I choose "internalConsole" in launch.json then I get the "EOFError" I mentioned.

{1} https://code.visualstudio.com/docs/getstarted/userinterface and https://code.visualstudio.com/api/ux-guidelines/activity-bar

barlop
  • 12,887
  • 8
  • 80
  • 109

1 Answers1

3

If you debug the program via Debug Python File in the play button options in the upper right corner (white icon), the configuration in launch.json will not be used.

enter image description here

The configuration in the launch.json file will only take effect if you debug the program through the deubrun panel (green icon). And you can choose different configurations for debugging.

enter image description here

Also, the DEBUG CONSOLE panel in vscode is only for output and not for input, so an error will occur when you configure "console" to "internalConsole" in launch.json.

console has three configurations,

"internalConsole": VS Code debug console.

"integratedTerminal": (default) VS Code Integrated Terminal.

"externalTerminal": Separate console window.

Both "integratedTerminal" and "externalTerminal" can complete the input.

"console": "integratedTerminal":

enter image description here

"console": "externalTerminal":

enter image description here

JialeDu
  • 6,021
  • 2
  • 5
  • 24