python-3.x – OSError:请求269892000和写入269188084

这里执行“array.tofile(fp)”行时出现OSError,其中写着“OSError:269892000 request and 269188084 written”.我能否知道这究竟是什么意思以及可能的解决方案是什么?

def write_array(fp, array, version=None, allow_pickle=True, pickle_kwargs=None):
    ...
    ...**strong text**
    _check_version(version)
    used_ver = _write_array_header(fp, header_data_from_array_1_0(array),
                                   version)
    # this warning can be removed when 1.9 has aged enough
    if version != (2, 0) and used_ver == (2, 0):
        warnings.warn("Stored array in format 2.0. It can only be"
                      "read by NumPy >= 1.9", UserWarning)

# Set buffer size to 16 MiB to hide the Python loop overhead.
buffersize = max(16 * 1024 ** 2 // array.itemsize, 1)

if array.dtype.hasobject:
    # We contain Python objects so we cannot write out the data
    # directly.  Instead, we will pickle it out with version 2 of the
    # pickle protocol.
    if not allow_pickle:
        raise ValueError("Object arrays cannot be saved when "
                         "allow_pickle=False")
    if pickle_kwargs is None:
        pickle_kwargs = {}
    pickle.dump(array, fp, protocol=2, **pickle_kwargs)
elif array.flags.f_contiguous and not array.flags.c_contiguous:
    if isfileobj(fp):
        array.T.tofile(fp)
    else:
        for chunk in numpy.nditer(
                array, flags=['external_loop', 'buffered', 'zerosize_ok'],
                buffersize=buffersize, order='F'):
            fp.write(chunk.tobytes('C'))
else:
    if isfileobj(fp):
        print("Entered1")
        array.tofile(fp)
    else:
        for chunk in numpy.nditer(
                array, flags=['external_loop', 'buffered', 'zerosize_ok'],
                buffersize=buffersize, order='C'):
            fp.write(chunk.tobytes('C'))

最佳答案 我得到了一个类似的错误,显然是因为savez存储文件的临时文件夹上的空间不足.根据
this Numpy bug report,解决方法是将TMPDIR = / path /设置为/ greater / drive / tmp.在我的例子中,异常是OSError而不是那里报告的IOError,我认为这是来自Python 3的变化.看起来像
fix到了
Numpy 1.12.0.

点赞