Python 3.8
h5py 2.10.0
Windows 10
I have found that when using any other mode, other than “r”, attributes associated with groups in external files are not accessible and an error is raised.
This works:
hfile = h5py.File("..\\casa\\_data\\_casa.h5", "r")
# Link to group in external file
hfile["/149901/20118/VRM_DATA"].attrs
Out[21]: <Attributes of HDF5 object at 1660502855488>
hfile.close()
This does not work:
hfile = h5py.File("..\\casa\\_data\\_casa.h5", "r+")
# link to group in external file
hfile["/149901/20118/VRM_DATA"].attrs
Traceback (most recent call last):
File "C:\Users\HIAPRC\Miniconda3\envs\py38\lib\site-packages\IPython\core\interactiveshell.py", line 3418, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-24-1af973f96bc2>", line 1, in <module>
hfile["/149901/20118/VRM_DATA"].attrs
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:\Users\HIAPRC\Miniconda3\envs\py38\lib\site-packages\h5py\_hl\group.py", line 264, in __getitem__
oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
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\h5o.pyx", line 190, in h5py.h5o.open
KeyError: "Unable to open object (unable to open external file, external link file name = '.\\sub_files\\casa_2021-01-13_10-03-51.h5')"
Is this a result of design or a bug?
Note: I am able to edit and save attributes using links to groups in external files using HDFView 3.1.1. So the external file is writable.