title: Delete dataset attribute from HDF5 file
body: <p>I have a hdf5 file I want to modify by deleting an attribute of one of the datasets and save the file without further changes. I can do this in hdfview, but I need something that's scriptable because it needs to be applied to a large number of files.</p>
  
  <p>I tried writing a script in python, using h5py:</p>
  
  <pre><code>import h5py
  inF = h5py.File("Filename.h5", 'r')
  dSet = inF['/data/myDataset']
  del dSet.attrs['myAttrName']
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   File "", line 1, in
       File "/usr/lib/python2.7/dist-packages/h5py/_hl/attrs.py",
    line 75, in <strong>delitem</strong>
        h5a.delete(self._id, self._e(name))   File "h5a.pyx", line 135, in h5py.h5a.delete (h5py/h5a.c:2682) KeyError: "unable to delete
    attribute (Attribute: Can't delete message)"</p>
  </blockquote>
  
  <p><code>print dSet.attrs['myAttrName']</code> produces the correct value, proving I can access the attribute.</p>
  
  <p>Is there any other ways to do this? Maybe using h5repack? </p>