0
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 时遇到问题 我有一段代码可以在一台计算机上运行,​​但是当我尝试在另一台计算机上运行它时,它似乎不起作用,并且我收到此错误 有关如何操作的任何建议?

4

1 回答 1

1

您的代码使用

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

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

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


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

如果插值是“无”,则不对 Agg、ps 和 pdf 后端执行插值。其他后端将回退到“最近”。

因此,如果您不使用Agg,pspdf后端,则可以将行更改为

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

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

于 2013-05-14T20:17:10.487 回答