Ctrl + D not working to exit Command Prompt nor Anaconda Powershell from Python

Ctrl + D no longer works to exit command prompt nor Anaconda Powershell when I'm in python. All it does is "^D". It worked when I first downloaded Anaconda for Python use. I've tested Ctrl + D in other applications such as Excel and Word and it works as intended.

I thought it was maybe something to do with Windows computers because I saw the following, "In Linux and MacOS environments, you can terminate standard input by outputting EOF (end of file) using the CTRL-D keyboard shortcut. In Windows, the CTRL-D key combination does not do the same. Lets look at how to accomplish this in Windows Command Prompt or Powershell." posted on this website - https://www.devdungeon.com/content/windows-eof-ctrl-d-equivalent

BUT, I had buddy of mine in one of my University classes do Ctrl + D to exit the python program thing and it worked for him. He has Windows 10 with Python 3.8.5

I know it worked about a week ago because that is when we downloaded Anaconda as a class and started to write some simple Python code.

Screen shot of Anaconda PowerShell and example of trying to exit Python 3.8.5

Screen shot of Anaconda PowerShell and example of trying to exit Python 3.8.5

Thanks for any advice or help!


Solution 1:

I thought it was maybe something to do with Windows computers[.]

My understanding is that Ctrl+D typically only works with Python under *Nix-like operating systems.

I know it worked about a week ago because that is when we downloaded Anaconda as a class and started to write some simple Python code.

If it worked previously, then something has changed but it might be difficult to pin down what. Notably, however, I recieve the same output as your screenshot with Ctrl+D, so it seems like some information is missing here.

I had buddy of mine in one of my University classes do Ctrl + D to exit the python program thing and it worked for him. He has Windows 10 with Python 3.8.5.

Again, there is likely something missing from this recollection then, as plain Ctrl+D doesn't normally exit the Python interpreter in a standard Windows command prompt (verified with the latest vanilla versions of Python 2.7, 3.6, 3.7 and 3.8).

As a total guess, perhaps your friend was working with Python in Linux via the Windows Subsystem for Linux (WSL) available in Windows 10 (possibly making Ctrl+D an option to exit the interpreter).

In any case, if you need a list of other options to exit the interpreter under Windows, I would suggest you see this answer.