Answer a question

Python fails to quit when using Ctrl-C in Powershell/Command Prompt, and instead gives out a "KeyboardInterrupt" string.

Recently I've reinstalled Windows 10. Before the reinstall Ctrl-C quit python (3.5/2.7) fine, with no output.

Does anyone know why this has started happening? Whether it's just a simple setting?

The only difference I can think of is I'm now on python 3.6. Ctrl-D works in Bash on Ubuntu on Windows, and Ctrl-C works fine in an activated anaconda python2 environment for quitting python.

Answers

This is a bug that recently appeared in Windows 10 Insider build 15002.

A work around is to change the Mapped Keys from Ctrl C to something like Ctrl K

If you are not familar how to do this, You can look up or at stty -a

You can run this command on each bash session that will map your Terminate to Ctrl + K

stty intr \^k

As a TEMP solution you could include this in your Bashrc so it is executed on each new session

This bug has been reported already on Github #1569

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐