我想加载一个.mat文件(v7.3),其中包含一个名为'A'的矩阵,来自MATLAB。我使用WIN7-64bit,Python 3.5.2 |在我自己的计算机上制作了它Anaconda 4.2.0(64位),h5py 2.6.0和numpy(1.12.1 + MKL)。使用的命令如下所示:
import numpy as np
import h5py
filepath='../../xxx.mat'
with h5py.File(filepath, 'r') as f:
x = f['A'][()]
然而,在使用Ubuntu 14.04LTS,Python 2.7.6,h5py 2.6.0和numpy(1.12.0)的另一台64位计算机上失败了。错误日志如下所示:
Traceback (most recent call last):
File "readmat_test.py", line 9, in <module>
with h5py.File(filepath, 'r') as f:
File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py", line 272, in __init__
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py", line 92, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip_build_root/h5py/h5py/_objects.c:2850)
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip_build_root/h5py/h5py/_objects.c:2808)
File "h5py/h5f.pyx", line 76, in h5py.h5f.open (/tmp/pip_build_root/h5py/h5py/h5f.c:2096)
IOError: Unable to open file (Unable to find a valid file signature)
我真的是Python的新手,只是不知道为什么会这样。这是由不同版本的软件包还是不同的操作系统引起的?还是其他任何原因?
非常感谢您的帮助:)
干杯, 最大