h5py.File() gives error message

Peter Otten __peter__ at web.de
Wed Oct 25 05:20:56 EDT 2017


C W wrote:

> Oh, I was running a debug file, that's why the path is different.
> 
> The file is here,
> https://www.dropbox.com/s/6jx4rzyg9xwl95m/train_catvnoncat.h5?dl=0
> 
> Is anyone able to get it working? Thank you!

Hm, that file seems to contain HTML and that causes an OSError here, too:

$ head -n3 datasets/train_catvnoncat.h5 

<!DOCTYPE HTML>
<html>

$ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import h5py
>>> train_dataset = h5py.File('datasets/train_catvnoncat.h5', "r")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/h5py/_hl/files.py", line 207, in __init__
    fid = make_fid(name, mode, userblock_size, fapl)
  File "/usr/lib/python3/dist-packages/h5py/_hl/files.py", line 79, in make_fid
    fid = h5f.open(name, h5f.ACC_RDONLY, fapl=fapl)
  File "h5f.pyx", line 71, in h5py.h5f.open (h5py/h5f.c:1806)
OSError: unable to open file (File accessibilty: Unable to open file)

It's not exactly what you see, but that may be due to differing software versions.
When I replace the HTML file with its namesake found at

https://github.com/lalxyy/NEU-MCM-Training-4/blob/master/code/datasets/train_catvnoncat.h5

I can open it:

$ file datasets/train_catvnoncat.h5 
datasets/train_catvnoncat.h5: Hierarchical Data Format (version 5) data

$ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import h5py
>>> train_dataset = h5py.File('datasets/train_catvnoncat.h5', "r")
>>>




More information about the Python-list mailing list