使用h5py访问属性时,出现“ IOError:无法读取属性(转换路径没有适当的功能)”

时间:2019-01-22 11:30:47

标签: python hdf5 h5py

python 2.7.13 / h5py 2.9.0

我尝试用h5py查看HDF5文件中的属性。

当我使用foo.attrs.values()或foo.attrs ['attribute_keys']

时发生错误

IOError:无法读取属性(转换路径没有适当的功能)

我可以使用attrs.keys()访问密钥

但是attrs.values(),attrs.items()无效。

#working in shell

>>> f=h5py.File('D:\read\sample.h5','r')

>>> f.attrs.keys()
[u'_NCProperties', u'satellite_name', u'instrument_name', u'data_processing_center', u'data_processing_mode', u'channel_spatial_resolution'... so on]

>>> f.attrs.values()

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    f.attrs.values()
  File "C:\Python27\lib\site-packages\h5py\_hl\base.py", line 374, in values
    return [self.get(x) for x in self]
  File "C:\Python27\lib\_abcoll.py", line 382, in get
return self[key]
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "C:\Python27\lib\site-packages\h5py\_hl\attrs.py", line 81, in __getitem__
    attr.read(arr, mtype=htype)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5a.pyx", line 355, in h5py.h5a.AttrID.read
  File "h5py\_proxy.pyx", line 36, in h5py._proxy.attr_rw
IOError: Unable to read attribute (no appropriate function for conversion path)

>>> f.attrs['file_name']

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    f.attrs['file_name']
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "C:\Python27\lib\site-packages\h5py\_hl\attrs.py", line 81, in __getitem__
    attr.read(arr, mtype=htype)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5a.pyx", line 355, in h5py.h5a.AttrID.read
  File "h5py\_proxy.pyx", line 36, in h5py._proxy.attr_rw
IOError: Unable to read attribute (no appropriate function for conversion path)

1 个答案:

答案 0 :(得分:0)

这已经是github上的一个公开问题:主题 OSError:无法读取属性(转换路径没有适当的功能)#719 https://github.com/h5py/h5py/issues/719

请点击链接...希望对您有帮助