简体   繁体   中英

How can I kill a python matplotlib script?

So I'm starting to play around with image processing with python in linux. so I run the code

from PIL import Image
from pylab import *

im = array(Image.open('sample.jpg').convert('L'))

im2 = 255 - im
imshow(im)

figure()
imshow(im2)
figure()
im3 = (100.0/255)*im + 100
imshow(im3)
figure()
im4 = 255.0 * (im/255.0)**2
imshow(im4)
show()

I create 4 figures. when i close these figures and want to run another code, i get the message:

Already Executing:
The Python Shell window is already
executing a command; please wait unit it is finished.

I would have to close the python shell window to execute another command. is there anyway to properly kill execution so i don't have to close the python shell everytime to run another script?

do you have the same problem if you add exit() at the end of the script (after the call to show )?

Edit on Unix you should be able to interrupt the execution of a program/script with ctrl+c

Which Python shell are you using? This behaviour seems quite unusual. If you use ipython , you could try to run ipython with -pylab -option to avoid threading issues.

If you don't use ipython, please tell us which variant you are using. The python ? Some IDE, like Spyder? It really depends.

I honestly recommend using ipython.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM