简体   繁体   中英

Updated matplotlib package does not work with wxPython

I'm running into a strange compatibility problem between wxPython and matplotlib.

import wx
import pylab
app = wx.App(False)
app.frame = wx.Frame(None)
app.frame.Centre()
app.frame.Show()

With matplotlib 1.5.0 or higher, this code will not run -- it hangs with no error on:

app = wx.App(False)

If I comment out import pylab , it works fine. import matplotlib does not cause an error, but import matplotlib.pyplot as plt does.

With matplotlib 1.4.2, this code works fine as is, including the pylab import.

I've looked for possible changes here: http://matplotlib.org/1.5.0/api/api_changes.html , but nothing appears relevant.

I'm on OSX El Capitan, using wxPython 3.0.2.0.

Any ideas about what's gone wrong?

This problem appears to be solved in matplotlib 1.5.1. In addition, the code above requires inclusion of the line matplotlib.use('WXAgg') . This ensures that the backend is set for wxPython, not for 'Qt4Agg', which is the matplotlib default.

More discussion of the issue is here: https://github.com/matplotlib/matplotlib/issues/5737

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