matplotlib pubsub python出现问题

2024-06-02 08:26:23 发布

您现在位置:Python中文网/ 问答频道 /正文

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有问题 我有一段代码在一台计算机上运行,但是当我试图在另一台计算机上运行时,它似乎不起作用,我得到了这个错误 有什么建议吗?在


Tags: inpymatplotliblibpackagesusrdistline
1条回答
网友
1楼 · 发布于 2024-06-02 08:26:23

你的代码使用

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

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

所以我猜您的两台机器运行的matplotlib版本不同,其中一个版本不够新。在


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

If interpolation is 'none', then no interpolation is performed on the Agg, ps and pdf backends. Other backends will fall back to ‘nearest’.

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

^{pr2}$

当然,如果您采用这种方法,可能还有其他代码也使用了更新的matplotlib特性。它们可能不那么容易修复。在

相关问题 更多 >