" RuntimeError:无法创建写结构"与pyplot

时间:2018-02-22 00:03:29

标签: python-2.7 matplotlib imshow

更新:

无论我试图绘制什么,我都会收到此消息:即使是这个

plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()

返回错误RuntimeError: Could not create write struct

我正在尝试在线绘制原始图像。我的Jupyter笔记本在带有端口转发的AWS实例上运行。

我的代码如下:

见上述更新

当我尝试这样做时,我收到以下错误消息,最终消息为RuntimeError: Could not create write struct

奇怪的是,完全相同的代码在本地运行良好。我可以整天查看图像。

因此,作为一项实验,我将图像从AWS中拉下并在本地运行,我可以看到它显示得很好。

我想,无论是我的Matplotlib还是jupyter笔记本都必须有问题。

我已经多次删除/重新安装了多个配置。我确保包的本地和AMI版本完全相同。

我不知道发生了什么事。

错误本身自然不是很有用。在谷歌搜索错误时,会有一些确切的字符串匹配结果,这总是很可怕。

其他随机的东西:

我使用的是Python 2.7 这两个图书馆都在Conda内管理 Jupyter:4.4.0 Matplotlib:2.1.2

<matplotlib.image.AxesImage at 0x7f261c1f2b50>
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/home/ubuntu/anaconda3/envs/pytorch_p27/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
    332                 pass
    333             else:
--> 334                 return printer(obj)
    335             # Finally look for special method names
    336             method = get_real_method(obj, self.print_method)

/home/ubuntu/anaconda3/envs/pytorch_p27/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in <lambda>(fig)
    238 
    239     if 'png' in formats:
--> 240         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    241     if 'retina' in formats or 'png2x' in formats:
    242         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/home/ubuntu/anaconda3/envs/pytorch_p27/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs)
    122 
    123     bytes_io = BytesIO()
--> 124     fig.canvas.print_figure(bytes_io, **kw)
    125     data = bytes_io.getvalue()
    126     if fmt == 'svg':

/home/ubuntu/anaconda3/envs/pytorch_p27/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2214                     orientation=orientation,
   2215                     dryrun=True,
-> 2216                     **kwargs)
   2217                 renderer = self.figure._cachedRenderer
   2218                 bbox_inches = self.figure.get_tightbbox(renderer)

/home/ubuntu/anaconda3/envs/pytorch_p27/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    524         try:
    525             _png.write_png(renderer._renderer, filename_or_obj,
--> 526                            self.figure.dpi, metadata=metadata)
    527         finally:
    528             if close:

RuntimeError: Could not create write struct

<matplotlib.figure.Figure at 0x7f2624b94950>

0 个答案:

没有答案