matplotlib pubsub python的问题

时间:2013-05-14 20:05:47

标签: python matplotlib wxpython

Traceback (most recent call last):
  File "PSPsolver1.py", line 520, in getchain
    Publisher().sendMessage(("show.mainframe"), msg)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/pubsub/pubsub1    /pub.py", line 750, in sendMessage
    self.__topicTree.sendMessage(aTopic, message, onTopicNeverCreated)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/pubsub/pubsub1/pub.py", line 423, in sendMessage
deliveryCount += node.sendMessage(message)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/pubsub/pubsub1/pub.py", line 261, in sendMessage
listener(message)
  File "PSPsolver1.py", line 1112, in showFrame
createfigure()
  File "PSPsolver1.py", line 927, in createfigure
x_ax.imshow(xcolors, cmap=cmap, interpolation='none')
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 6749, in imshow
filterrad=filterrad, resample=resample, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/image.py", line 547, in __init__
**kwargs
  File "/usr/lib/pymodules/python2.7/matplotlib/image.py", line 94, in __init__
    self.set_interpolation(interpolation)
  File "/usr/lib/pymodules/python2.7/matplotlib/image.py", line 458, in set_interpolation
raise ValueError('Illegal interpolation string')
 ValueError: Illegal interpolation string

我遇到matplotlib问题 我有一段代码正在一台计算机上运行,​​但是当我尝试在另一台计算机上运行它时,它似乎无法工作,我收到此错误 关于该怎么做的任何建议?

1 个答案:

答案 0 :(得分:1)

您的代码使用

x_ax.imshow(xcolors, cmap=cmap, interpolation='none')

PSPsolver1.py的第927行。在matplotlib版本1.0.1和1.2.0之间的某个时间引入了参数interpolation='none'

所以我的猜测是你的两台机器运行不同版本的matplotlib,而且一个版本不够新。


解决问题的一种方法是(当然)更新旧版本的matplotlib。如果这不是一个选项,或者您不想这样做,请注意the docs say

  

如果插值为'none',则不对插值执行插值   Agg,ps和pdf后端。其他后端将回归到“最近”。

因此,如果您未使用Aggpspdf后端,则可以将行更改为

x_ax.imshow(xcolors, cmap=cmap, interpolation='nearest')

当然,如果你走这条路,可能还有其他代码片段也使用更新的matplotlib功能。它们可能不那么容易修复。