当前位置: 代码迷 >> 综合 >> scipy.io.matlab IOError: could not read bytes
  详细解决方案

scipy.io.matlab IOError: could not read bytes

热度:31   发布时间:2023-12-15 17:10:41.0

python2.7

scipy 1.2.2

 

代码:

import scipy
from scipy.io import matlab
mat = matlab.loadmat(filename)

报错:

Traceback (most recent call last):File "syn_data/rep_pickle.py", line 57, in <module>frames, labels = load_rep_dataset(mat_file)File "syn_data/rep_pickle.py", line 32, in load_rep_datasetmat = matlab.loadmat(filename)File "/home/user/.local/lib/python2.7/site-packages/scipy/io/matlab/mio.py", line 208, in loadmatmatfile_dict = MR.get_variables(variable_names)File "/home/user/.local/lib/python2.7/site-packages/scipy/io/matlab/mio5.py", line 292, in get_variablesres = self.read_var_array(hdr, process)File "/home/user/.local/lib/python2.7/site-packages/scipy/io/matlab/mio5.py", line 252, in read_var_arrayreturn self._matrix_reader.array_from_header(header, process)File "mio5_utils.pyx", line 675, in scipy.io.matlab.mio5_utils.VarReader5.array_from_headerFile "mio5_utils.pyx", line 721, in scipy.io.matlab.mio5_utils.VarReader5.array_from_headerFile "mio5_utils.pyx", line 894, in scipy.io.matlab.mio5_utils.VarReader5.read_cellsFile "mio5_utils.pyx", line 673, in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrixFile "mio5_utils.pyx", line 705, in scipy.io.matlab.mio5_utils.VarReader5.array_from_headerFile "mio5_utils.pyx", line 778, in scipy.io.matlab.mio5_utils.VarReader5.read_real_complexFile "mio5_utils.pyx", line 450, in scipy.io.matlab.mio5_utils.VarReader5.read_numericFile "mio5_utils.pyx", line 355, in scipy.io.matlab.mio5_utils.VarReader5.read_elementFile "streams.pyx", line 195, in scipy.io.matlab.streams.ZlibInputStream.read_stringFile "streams.pyx", line 188, in scipy.io.matlab.streams.ZlibInputStream.read_into
IOError: could not read bytes

原因:.mat文件不完整,可能是由于下载或者上传中断的原因造成的。

解决方法:重新下载或上传出错的.mat文件。

致谢:https://github.com/anishathalye/neural-style/issues/47

  相关解决方案