Ask Your Question
0

How to terminate a running python code within IDLE?

asked 2014-07-18 15:49:13 -0600

ypwang gravatar image

Hi everyone,

A lot of times, I would like to terminate a contingency analysis process (that might take more than half hour) in the middle in the python shell of IDLE, so that I can test my another script. I tried Ctrl+C and Ctrl+Z,but neither worked. I searched through all the drop-down menus of IDLE, no options seem to solve my issue.

Does anyone know the trick? Really appreciate it!

Regards,

Yp

edit retag flag offensive close merge delete

Comments

1

So far, I had to close the whole python shell window to stop it. But the problem is that I have to reopen IDLE and reload my script.

ypwang gravatar imageypwang ( 2014-07-19 15:48:49 -0600 )edit

I'm not sure what the correct answer is here. I suspect you are close to the optimal solution. This is one of the reasons I stopped using IDLE, now I use a standard python console + a normal text editor.

JervisW gravatar imageJervisW ( 2014-08-03 20:22:39 -0600 )edit

So far, I still stop the process by closing the IDLE python shell terminal and restart everything over. Hope someone who know a smarter answer contribute his/her trick to this community.

ypwang gravatar imageypwang ( 2014-08-13 21:59:14 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
1

answered 2014-08-18 05:28:52 -0600

rimux gravatar image

I suggest you not to use python IDLE if possible as it is very simple and not very programming-friendly enviroment. I would recommend to use PyScripter or Notepad++, both of them are free and much better shells for writing in python. In PyScripter you can terminate running program by pressing Ctrl-Alt-F9 ('Abort debugging'). In Notepad++ for running python programs you will need to install plugin NppExec and run python scripts by pressing F6 (for the very first time you will need to enter this line for make it work: C:\Python27\python.exe "$(FULLCURRENTPATH)" ). After program starts, if you'll press F6 again "Terminate" button appears and you can kill active process. Try this and you will never ever want to come back using native python IDLE :)

edit flag offensive delete link more
1

answered 2014-08-13 22:53:48 -0600

ypwang gravatar image

updated 2014-09-16 10:49:23 -0600

I just figured out a way to make "Ctrl +C" work regardless of how large your python code is: run python from Windows COMMAND LINE mode. Here is a useful link explaining HOW in case any one don't know how to set up command line run mode.

http://stackoverflow.com/questions/46...

Plus, running command line is a little bit faster.

edit flag offensive delete link more

Comments

Yes, it work for me. Inside idle, Control-C stops the following program: while True: print 'hello'

jconto gravatar imagejconto ( 2014-08-14 18:36:04 -0600 )edit

Actually, Ctrl+C doesn't work in IDLE for cases that take a long time to solve (e.g. ACCC running on more than a thousand number of contingencies). Well, I tested it with success only on cases that only takes less than 1 minute. Don't know why.

ypwang gravatar imageypwang ( 2014-08-15 09:44:22 -0600 )edit
0

answered 2016-09-22 02:46:21 -0600

Hi I faced with the same issue. The reason -- it was another input language (in my case it was Russian). So if you are using some another input languages (in addition to English), so please switch to English and <ctrl+c> will work properly.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2014-07-18 15:49:13 -0600

Seen: 20,344 times

Last updated: Sep 22 '16