【问题标题】:"IOError: Unable to read attribute (no appropriate function for conversion path)" when access to attribute with h5py使用 h5py 访问属性时出现“IOError:无法读取属性(转换路径没有合适的功能)”
【发布时间】:2019-01-22 19:35:28
【问题描述】:

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)

【问题讨论】:

    标签: python hdf5 h5py


    【解决方案1】:

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

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

    【讨论】:

    • 感谢您的回答。我应该使用“netCDF4-python”还是“h5netcdf”库来查看属性?
    猜你喜欢
    • 1970-01-01
    • 2016-02-24
    • 2023-03-20
    • 2020-11-23
    • 1970-01-01
    • 1970-01-01
    • 2019-10-20
    • 1970-01-01
    • 2014-07-28
    相关资源
    最近更新 更多