0

I am trying to upload a dataset from HDF5 into Python with the following code:

data = h5py.File('data.h5', 'r')

Whenever I do this, I keep getting the error

Unable to open file (unable to open file: name = 'data.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

I've done this with other datasets and this error keeps occurring. I was able to successfully upload only one dataset previously, but I cannot upload other datasets. The files are in my downloads. What is exactly causing this problem?

1
  • 1
    But is 'downloads' the current directory, or on the Python path? Most likely it can't open the file because it isn't looking in the right place. That's a basic Python issue, not specific to h5py Commented Oct 12, 2019 at 3:58

2 Answers 2

1

Double-check the path you're in. It looks like that file isn't in your workspace as indicated by error message = 'No such file or directory'. Make sure that the file is in that folder you're running your script from, or provide an absolute path to it. If you're using Notebooks, use the %ls command to list all files in that working directory.

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

Comments

0

If you are using VS code, then ensure that you are running python in the same directory (folder) as the data.h5 file.

I was also having this issue. So I tried to cd into that directory and the file gets loaded.

Thanks.

Comments

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.