简体   繁体   English

如何杀死python matplotlib脚本?

[英]How can I kill a python matplotlib script?

So I'm starting to play around with image processing with python in linux. 因此,我开始尝试在Linux中使用python处理图像。 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. 我创建4个数字。 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. 我必须关闭python shell窗口才能执行另一个命令。 is there anyway to properly kill execution so i don't have to close the python shell everytime to run another script? 无论如何,有没有适当地终止执行,所以我不必每次运行另一个脚本时都关闭python shell?

do you have the same problem if you add exit() at the end of the script (after the call to show )? 如果在脚本末尾(在show调用之后exit()添加exit() ,是否会遇到相同的问题?

Edit on Unix you should be able to interrupt the execution of a program/script with ctrl+c 在Unix上进行编辑 ,您应该能够使用ctrl + c中断程序/脚本的执行

Which Python shell are you using? 您正在使用哪个Python Shell? This behaviour seems quite unusual. 这种行为似乎很不寻常。 If you use ipython , you could try to run ipython with -pylab -option to avoid threading issues. 如果使用ipython ,则可以尝试使用-pylab -option运行ipython以避免线程问题。

If you don't use ipython, please tell us which variant you are using. 如果您不使用ipython,请告诉我们您使用的是哪个版本。 The python ? python Some IDE, like Spyder? 一些IDE,例如Spyder? It really depends. 真的要看

I honestly recommend using ipython. 老实说,我建议使用ipython。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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