当我实现代码的ginput部分时,就发出了警告。
def twoClicks(color_img):
from pylab import ginput, rcParams, imshow, draw, title, axis, close
rcParams['figure.figsize'] = 12, 8
imshow(color_img, interpolation='nearest', aspect='equal')
title("Click the image twice")
axis('off')
user_input = ginput(2)
draw()
close()
print(user_input)
return执行上述代码将给我以下信息:
/usr/lib/python3.3/site-packages/matplotlib/backend_bases.py:2407: MatplotlibDeprecationWarning:使用默认事件循环,直到特定于该GUI的函数实现为warnings.warn(str,mplDeprecation)
我想知道我在做什么,那就是发出警告,以及如何以正确的方式来做这件事。
提前感谢!
我在linux中,matplotlib输出由默认接口(可能是GTK)处理。
发布于 2014-03-25 15:18:05
查看python教程中如何抑制警告,http://docs.python.org/2/library/warnings.html#temporarily-suppressing-warnings
import warnings
def fxn():
warnings.warn("deprecated", DeprecationWarning)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
fxn()发布于 2017-04-17 09:26:26
具体而言,在这种情况下,请使用:
warnings.filterwarnings("ignore",".*GUI is implemented.*")这适用于在警告中查找的模式,这意味着仍将报告其他警告。
https://stackoverflow.com/questions/20003744
复制相似问题