Reputation: 368
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?
Upvotes: 0
Views: 5628
Reputation: 56
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.
Upvotes: 0
Reputation: 91
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.
Upvotes: 1