简体   繁体   English

更新的matplotlib软件包不适用于wxPython

[英]Updated matplotlib package does not work with wxPython

I'm running into a strange compatibility problem between wxPython and matplotlib. 我遇到了wxPython和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: 使用matplotlib 1.5.0或更高版本时,此代码将不会运行-挂起时没有错误:

app = wx.App(False)

If I comment out import pylab , it works fine. 如果我注释了import pylab ,它可以正常工作。 import matplotlib does not cause an error, but import matplotlib.pyplot as plt does. import matplotlib不会导致错误,但是import matplotlib.pyplot as plt一样import matplotlib.pyplot as plt

With matplotlib 1.4.2, this code works fine as is, including the pylab import. 对于matplotlib 1.4.2,此代码可以正常运行,包括pylab导入。

I've looked for possible changes here: http://matplotlib.org/1.5.0/api/api_changes.html , but nothing appears relevant. 我在这里寻找可能的更改: http : //matplotlib.org/1.5.0/api/api_changes.html ,但似乎没有相关内容。

I'm on OSX El Capitan, using wxPython 3.0.2.0. 我在使用wxPython 3.0.2.0的OSX El Capitan。

Any ideas about what's gone wrong? 关于出了什么问题的任何想法?

This problem appears to be solved in matplotlib 1.5.1. 该问题似乎在matplotlib 1.5.1中已解决。 In addition, the code above requires inclusion of the line matplotlib.use('WXAgg') . 另外,上面的代码要求包含行matplotlib.use('WXAgg') This ensures that the backend is set for wxPython, not for 'Qt4Agg', which is the matplotlib default. 这样可确保为wxPython而不是'Qt4Agg'设置后端,这是matplotlib的默认设置。

More discussion of the issue is here: https://github.com/matplotlib/matplotlib/issues/5737 关于这个问题的更多讨论在这里: https : //github.com/matplotlib/matplotlib/issues/5737

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

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