the python shell window is already executing a command

Seymore4Head Seymore4Head at Hotmail.invalid
Wed Sep 17 17:55:06 CEST 2014


On Wed, 17 Sep 2014 04:02:16 -0400, Terry Reedy <tjreedy at udel.edu>
wrote:

>On 9/16/2014 10:17 PM, Seymore4Head wrote:
>> I have googled for a solution to this problem.  None I have tried
>> worked.
>>
>> I have a very short program that runs for a count of 20 and ends.
>> What I do is click on the IDLE window and without making any changes I
>> just hit f5 to rerun the program.
>
>Do you mean click on the Idle editor window?
>
>> Sometimes I get the error "the python shell window is already
>> executing a command" and sometimes not.
>>
>> I am using XP and Python 3.4.1.
>>
>> Is there a way to rerun a program without getting this error?
>
>Normally, hitting f5 kills the previous process if it is still running 
>and starts the one in the editor.  Please post a minimal program that 
>exhibits the problem.

It happens in almost every program I have written.  I just tried this
one again.  I could run the program by pushing f5.  The first couple
of times it would run again by switching back to IDLE and pressing f5,
but after the second or third time, it gives an error that the python
shell window is already executing a command.

If I make a change to the program, like adding or deleting a 0 from
"rounds" the program will run without generating an error, but if I
try to re run the program without changing anything, I get the error
almost every time.


Here is one.

import random
count =0
rounds=1000
heads=0
tails=0
ht=[0,1]
while count<rounds:
    coin=random.choice(ht)
    if coin == 0:
        heads=heads+1
    elif coin == 1:
        tails=tails+1
    count = count + 1
print (heads,tails)
print ('Heads {:.2%} Tails "{:.2%} "'.format(heads/rounds,
tails/rounds))



More information about the Python-list mailing list