0

When I tried to open an .hdf5 file with h5py:

import h5py

file=h5py.open(".../f.hdf5",'r'),

The following error was raised:

h5py/h5f.pyx in h5py.h5f.open()

OSError: Unable to open file (unable to lock file, errno = 11, error message = 'Resource temporarily unavailable')

1 Answer 1

4

Solutions: The error could be solved for opening .hdf5 files as below:

file= h5py.File(file_path,'r')

  1. close the files using file.close() or
  2. import os
    os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"

Then the error while opening the file will be gone and you can keep working on that file.

Sign up to request clarification or add additional context in comments.

3 Comments

Better yet, use the Python file context manager and you don't have to remember to close the file -- use with h5py.File(file_path,'r') as file:. This avoids problems when the program terminates unexpectedly and leaves the file open (because you didn't get to file.close() )
The HDF5_USE_FILE_LOCKING option solved my problem. Please add more details on this
I'd definitely advocate the with-statement solution provided by @kcw78. But in my case I used the mode 'r+' so my problem did not go away until I added the file.close() as the last line of the with-statement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.