Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

h5py.File() gives error message

2,707 views
Skip to first unread message

C W

unread,
Oct 24, 2017, 8:38:59 PM10/24/17
to
Dear list,

The following Python code gives an error message

# Python code starts here:
import numpy as np
import h5py
train_dataset = h5py.File('datasets/train_catvnoncat.h5', "r")

# Python code ends

The error message:

train_dataset = h5py.File('train_catvnoncat.h5', "r")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/M/anaconda/lib/python3.6/site-packages/h5py/_hl/files.py",
line 269, in __init__
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "/Users/M/anaconda/lib/python3.6/site-packages/h5py/_hl/files.py",
line 99, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 78, in h5py.h5f.open
OSError: Unable to open file (unable to open file: name =
'train_catvnoncat.h5', errno = 2, error message = 'No such file or
directory', flags = 0, o_flags = 0)

My directory is correct, and the dataset folder with file is there.

Why error message? Is it h5py.File() or is it my file? Everything seems
pretty simple, what's going on?

Thank you!

Rob Gaddi

unread,
Oct 24, 2017, 9:02:39 PM10/24/17
to
Be 100% sure your directory is correct. Try it again with an absolute
path to the file. Windows makes it far too easy for the working
directory of a program to be other than what you think it is.

--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.

C W

unread,
Oct 25, 2017, 3:22:16 AM10/25/17
to
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!

On Tue, Oct 24, 2017 at 10:37 PM, Dennis Lee Bieber <wlf...@ix.netcom.com>
wrote:

> On Tue, 24 Oct 2017 18:02:26 -0700, Rob Gaddi
> <rga...@highlandtechnology.invalid> declaimed the following:
>
> Whoops, I may have gotten the wrong level of quoting -- my
> apologies if
> so (I did have agent fetch the original posting, but might not have had
> that active when I hit "reply")
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Peter Otten

unread,
Oct 25, 2017, 5:21:39 AM10/25/17
to
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.

C W

unread,
Oct 25, 2017, 9:58:56 AM10/25/17
to
wow, thanks so much! I don't know how you figured that it's HTML, but
that's awesome!

Mike

On Wed, Oct 25, 2017 at 5:20 AM, Peter Otten <__pet...@web.de> wrote:

> 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/cod
> e/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")
> >>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
0 new messages