Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix the deprecation warning that comes with pylab.pause?

A short python program to demonstrate a bug I keep running into:

import pylab
pylab.ion()
pylab.title('doom')
pylab.pause(0)

If I run it, it works fine, but I get this warning:

/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py:2280: MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented

If I remove the pause line, then I don't get the warning, but my plot ceases to exist as soon as the program finishes.

I should like an elegant way to get the behaviour without the warning. Can anyone help?

like image 863
John Lawrence Aspden Avatar asked Apr 04 '14 21:04

John Lawrence Aspden


1 Answers

Use the warnings module. https://pymotw.com/2/warnings/

import warnings
..
..
warnings.filterwarnings("ignore",".*GUI is implemented.*")

This looks for the pattern 'Gui is implemented' in any warning being issued and ignores it but allows other warnings to be reported.

like image 122
Rolf of Saxony Avatar answered Oct 10 '22 03:10

Rolf of Saxony