tfg250
tfg250

Reputation: 436

CTRL-C causes forrtl: error (200) rather than python KeyboardInterrupt exception

I'm trying to do the exact same thing as this question:

How to prevent a block of code from being interrupted by KeyboardInterrupt in Python? (sorry, not enough rep yet to post this as a comment there)

However both of the top answers posted there aren't working for me. When I hit CTRL+C with either of those solutions in place, the script still closes immediately with:

forrtl: error (200): program aborting due to control-C event

The code I'm working on is fairly long and includes quite a few imported modules. Am I correct to assume one of these modules is interfering with the normal behavior of KeyboardInterrupt? If so, how can I figure out which one?

(I'm running python 2.7.6, 32bit on Windows)

thanks.

Upvotes: 14

Views: 11640

Answers (2)

Andrea Bragantini
Andrea Bragantini

Reputation: 56

A part from those specific cases above (question and above answer), for those of you still stuck in this

forrtl: error (200): program aborting due to control-C event

trying to obtain a normal behaviour of CTRL+C KeyboardInterrupt during the execution of a program (in my case it's a training procedure of neural network model with PyTorch executed within PyCharm IDE on Windows 10 and anaconda python3.8).

It turned out to be a problem of corrupted anaconda environment or either some package within. For me, reinstalling the previous version of PyCharm (downgrading from 2022 to 2021) and replacing the old environment with a brand new one, solved the problem. The KeyboardInterrupt turned back to its old useful behaviour, stopping the program but not exiting the python console at CTRL+C event.

Hope it helped someone.

Upvotes: 1

tfg250
tfg250

Reputation: 436

Scipy was causing the problem. The link below provides a solution, note that this is not unique to scipy.stats, but also occurs with other scipy functions.

Ctrl-C crashes Python after importing scipy.stats

Upvotes: 7

Related Questions