Reputation:
I am using the Python Language. Each time I press f5 to run the program, it displays "EOFError: EOF when reading a line" in the debug console and points an error to the first line. When I try to run the same program in Python IDLE (3.8 64-bit), it runs perfectly. When I delete the first line of code (since the error is there), the error is the same but now on the new first line. When there is a genuine error, such as syntax, the debug console points that error out for me. But when I fix it, the same EOF error continues.
year = int(input ("Enter a year: "))
if ((year % 100) == 0 and (year % 400) == 0) or ((year % 100) != 0 and (year % 4) == 0):
print('In', year, 'February has 29 days.')
else:
print('In', year, 'February has 28 days.')
Here is a screenshot of the code and error message: https://i.sstatic.net/9GKiD.png
Upvotes: 0
Views: 1779
Reputation: 10374
I reproduced the problem you described, and the reason is the way the debug code is output.
When we use "console": "internalConsole",
the result will be output to "DEBUG CONSOLE
", and this terminal of VSCcode 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".
The solution is to change the output mode of the debugging code.
For the code that needs to be entered, we can use "console": "integratedTerminal",
or "console": "externalTerminal",
when we don't set it, VSCode uses "console" : "integratedTerminal"
by default.
Reference: console in VSCode.
Upvotes: 2
Reputation:
I fixed it by changing the launch.json
settings to:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
}
]
}
Upvotes: 0