Skip to content Skip to sidebar Skip to footer

Python 3: Eof When Reading A Line (visual Studio Code)

I use visual studio code to program in Python, and whenever I try to take user input, Visual Studio Code throws me an 'EOF when reading a line' at that specific line. However, this

Solution 1:

I reproduced the problem you described:

enter image description here

Reason: When we use "console": "internalConsole", the result will be output to "DEBUG CONSOLE", and this terminal of VSCode is currently only used for display output. When the code needs to be input but input is not received, it will throw "EOF" "(End of file), "There is an unexpected error at the end of the file".

Answer : please change the output mode of the debugging code. (in settings.json file)

  1. For the code that needs to be entered, we can use "console": "integratedTerminal",

    enter image description here

  2. or use "console": "externalTerminal",

    enter image description here

Reference: console in VSCode.

Solution 2:

Using the Microsoft Visual Studio Code (and the debug window for code that does not require input), I right-clicked on the code and from the submenu selected the Run Python File in Terminal option. Rather than executing in the Debug tab, it executed in the Terminal tab. I was able to enter an input there and test the input value.

enter image description here

Post a Comment for "Python 3: Eof When Reading A Line (visual Studio Code)"