First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

How to terminate a running python code within IDLE?

asked Jul 18 '14

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

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 (Jul 19 '14)

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 (Aug 4 '14)

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 (Aug 14 '14)

3 answers

Sort by » oldest newest most voted
1

answered Aug 18 '14

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 :)

link
1

answered Aug 14 '14

ypwang gravatar image

updated Sep 16 '14

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.

link

Comments

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

jconto gravatar imagejconto (Aug 15 '14)

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 (Aug 15 '14)
0

answered Sep 22 '16

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.

link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

Stats

Asked: Jul 18 '14

Seen: 21,620 times

Last updated: Sep 22 '16