H5py: OSError: Unable to create link (name already exists)

Created on 18 Apr 2020  路  4Comments  路  Source: h5py/h5py

I think I am the only one who meet with this issue, because I never consult a solution on the Internet.
Here is my environment:

  • Windows 10
  • Python 3.6
  • h5py version (e.g. 2.10.0)
  • When attempting to save Keras model, the issue happened:
model.save('pointer_network_keras_1.h5')

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 202, in h5py.h5o.link
OSError: Unable to create link (name already exists)

It's wired because my other projects work fine.

no-action-taken

Most helpful comment

Leaving a comment here because I had a very similar h5py issue. I was using scanpy but receiving the same error messages, and couldn't find my solution anywhere online. Turns out, the issue was that in my anndata.var dataframe I had a column which was identical to the index (it was the column I used to define the index). I would guess that this was causing problems because you can't store two columns with the same name?

Anyway, the simple solution for me was to delete the column which was identical to the index. Took me a long time to get to the bottom of this and hopefully this comment may save someone time in the future.

All 4 comments

You probably need to debug that with Keras first. That's a legitimate HDF5 error that normally means something tried to create a second object with the same name. It's more likely to be a bug in whatever code is using h5py, not h5py itself.

Leaving a comment here because I had a very similar h5py issue. I was using scanpy but receiving the same error messages, and couldn't find my solution anywhere online. Turns out, the issue was that in my anndata.var dataframe I had a column which was identical to the index (it was the column I used to define the index). I would guess that this was causing problems because you can't store two columns with the same name?

Anyway, the simple solution for me was to delete the column which was identical to the index. Took me a long time to get to the bottom of this and hopefully this comment may save someone time in the future.

Generally, names in an HDF5 group need to be different (like keys in a dict, or filenames in a folder). But it's up to the higher-level code (e.g. scanpy) how it represents a dataframe in HDF5.

@haskankaya absolute hero! 馃挴
You helped me, I also had problems with scanpy.
Turns out that the issue arises when name of index is same as a column name, so renaming the index or column would be adequate for a workaround. I posted an issue on scanpy's github here:
https://github.com/theislab/anndata/issues/452

Thanks to h5py for lending space on your github issues to scanpy problems ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dnellurv picture dnellurv  路  3Comments

mihaimaruseac picture mihaimaruseac  路  4Comments

ax3l picture ax3l  路  3Comments

ivirshup picture ivirshup  路  8Comments

biocyberman picture biocyberman  路  6Comments