Matplotlib在Ubuntu 18.04上引发MemoryError,但在Windows 10上不引发

时间:2019-04-20 12:46:26

标签: python-3.x matplotlib

我正在Ubuntu机器上为Windows用户开发软件。

它的作用: 对数千个图像进行对象检测,并将结果与​​某些测量数据(示波器数据:〜200MB,5000万个数据值)进行比较。最后,将结果绘制并保存。在此步骤之后,程序前进到下一个数据集,依此类推。在第二个数据集,我得到了错误。

我已经安装了Ubuntu和Windows 10 64位版本。 Python3 64bit应该在两个操作系统上都可以运行。

要启动python脚本,只需运行它,它就可以在一个大的for循环中完成所有工作。基本步骤:

  1. 在数据集1的图像上检测对象
  2. 进行一些计算
  3. 使用matplotlib绘制结果并保存到文件
  4. 前进到下一个数据集
  5. 在数据集2的图像上检测对象
  6. 进行一些计算
  7. 绘制结果[MemoryError]

由于仅复制整个ErrorMessage会破坏其格式,因此我必须在每行之后插入换行符以使其可读:

Progress: Datensatz 1/2 ; Sequenz 2/4 ; Frame 99/101

Progress: Datensatz 1/2 ; Sequenz 2/4 ; Frame 100/101

Progress: Datensatz 1/2 ; Sequenz 2/4 ; Frame 101/101

Progress: Plot...

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py", line 1496, in _getbool_axis
    return self.obj._take(inds, axis=axis)

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py", line 2789, in _take
    verify=True)

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/internals.py", line 4539, in take
    axis=axis, allow_dups=True)

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/internals.py", line 4421, in reindex_indexer
    fill_tuple=(fill_value,))

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/internals.py", line 4501, in _slice_take_blocks_ax0
    fill_tuple=None))

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/internals.py", line 1254, in take_nd
    allow_fill=False)

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/algorithms.py", line 1653, in take_nd
    out = np.empty(out_shape, dtype=dtype, order='F')

MemoryError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/artur/Desktop/UHF_Analyse_Artur/Firefly_Gesamt/UHF_Analyse.py", line 794, in <module>
    plot(gap_list, deg_list, timestamp, trc)

  File "/home/artur/Desktop/UHF_Analyse_Artur/Firefly_Gesamt/UHF_Analyse.py", line 306, in plot
    xticks = np.arange(df_oszi.index[0], df_oszi.index[-1], 1))

  File "/usr/local/lib/python3.6/dist-packages/pandas/plotting/_core.py", line 2941, in __call__
    sort_columns=sort_columns, **kwds)

  File "/usr/local/lib/python3.6/dist-packages/pandas/plotting/_core.py", line 1977, in plot_frame
    **kwds)

  File "/usr/local/lib/python3.6/dist-packages/pandas/plotting/_core.py", line 1804, in _plot
    plot_obj.generate()

  File "/usr/local/lib/python3.6/dist-packages/pandas/plotting/_core.py", line 258, in generate
    self._compute_plot_data()

  File "/usr/local/lib/python3.6/dist-packages/pandas/plotting/_core.py", line 363, in _compute_plot_data
    "timedelta"])

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py", line 3091, in select_dtypes
    return self.loc[com._get_info_slice(self, dtype_indexer)]

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py", line 1472, in __getitem__
    return self._getitem_tuple(key)

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py", line 890, in _getitem_tuple
    retval = getattr(retval, self.name)._getitem_axis(key, axis=i)

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py", line 1868, in _getitem_axis
    return self._getbool_axis(key, axis=axis)

  File "/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py", line 1498, in _getbool_axis
    raise self._exception(detail)

KeyError: MemoryError()

>>> Exception in Tkinter callback

Traceback (most recent call last):

  File "/usr/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)

  File "/usr/lib/python3.6/tkinter/__init__.py", line 749, in callit
    func(*args)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/_backend_tk.py", line 346, in idle_draw
    self.draw()

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 9, in draw
    super(FigureCanvasTkAgg, self).draw()

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_agg.py", line 402, in draw
    self.figure.draw(self.renderer)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py", line 1649, in draw
    renderer, self, artists, self.suppressComposite)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_base.py", line 2610, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/lines.py", line 736, in draw
    self._transform_path(subslice)

  File "/usr/local/lib/python3.6/dist-packages/matplotlib/lines.py", line 688, in _transform_path
    _path = Path(np.asarray(xy).T,

  File "/usr/local/lib/python3.6/dist-packages/numpy/core/numeric.py", line 492, in asarray
    return array(a, dtype, copy=False, order=order)

MemoryError

关于这一点的有趣之处在于,我在Ubuntu上获得了MemoryError,而在Windows上却没有。我一直认为python在Linux上运行更加可靠。知道如何解决这个问题吗?

0 个答案:

没有答案