"IOError: Unable to read attribute (no appropriate function for conversion path)" when access to attribute with h5py

"IOError: Unable to read attribute (no appropriate function for conversion path)" when access to attribute with 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)

这已经是 github 上的未决问题:主题 OSError:无法读取属性(转换路径没有合适的函数)#719 https://github.com/h5py/h5py/issues/719

请关注link ...希望对您有所帮助