Re: h5py and python 3.3

1,347 views
Skip to first unread message

Andrew Collette

unread,
Dec 5, 2012, 1:21:48 PM12/5/12
to h5...@googlegroups.com
Hi Alex,

> I can't get h5py 2.1.0 to import in python 3.3 on OS X 10.8. I don't know
> if this is also the
> case on other architectures. However -- it works fine on python 3.2.

Yes, this is an issue with Python 3.3... there are some lingering
relative imports that have to be cleaned up. A patch has already been
contributed so this will be in the next bugfix release.

> This seems similar to the question a few posts back about 10.8, where
> somebody was seeing the same 'cannot import name _errors' and the
> answer was to not use the system python -- but here I am not using system
> python and it works for older python versions. So it may or not be related.

The "cannot import name _errors" unfortunately can mean many things;
it's the first module h5py tries to import, so you get this for a wide
variety of compilation errors, linker errors, etc.

> Also -- why is there no __version__ string for h5py?

I had always thought of it being for SVN/CVS per-file versioning. PEP
396 suggests otherwise. I'm certainly happy to include it if people
want. For the moment you can always get the full version string as
h5py.version.version.

Andrew

Alex Conley

unread,
Dec 5, 2012, 5:50:43 PM12/5/12
to h5...@googlegroups.com


On Wednesday, December 5, 2012 11:21:48 AM UTC-7, Andrew Collette wrote:

Yes, this is an issue with Python 3.3... there are some lingering
relative imports that have to be cleaned up.  A patch has already been
contributed so this will be in the next bugfix release.

Ok, great, I can wait.  Just happy to know it isn't me!

 
> Also -- why is there no __version__ string for h5py?

I had always thought of it being for SVN/CVS per-file versioning.  PEP
396 suggests otherwise.  I'm certainly happy to include it if people
want.  For the moment you can always get the full version string as
h5py.version.version.


Add that string would certainly get my vote.

Thanks,
Alex

 

Matthew Turk

unread,
Mar 13, 2013, 10:23:24 PM3/13/13
to h5...@googlegroups.com
Hi Andrew,

Much like Alex, I'm running with a hand-compiled Python 3.3 and
running into much the same error.

On Wed, Dec 5, 2012 at 1:21 PM, Andrew Collette
<andrew....@gmail.com> wrote:
> Hi Alex,
>
>> I can't get h5py 2.1.0 to import in python 3.3 on OS X 10.8. I don't know
>> if this is also the
>> case on other architectures. However -- it works fine on python 3.2.
>
> Yes, this is an issue with Python 3.3... there are some lingering
> relative imports that have to be cleaned up. A patch has already been
> contributed so this will be in the next bugfix release.

On h5py 2.1.2, I see something similar:

$ python3.3 -c "import h5py"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/mturk/yt-x86_64-py3/lib/python3.3/site-packages/h5py/__init__.py",
line 7, in <module>
from h5py import h5a, h5d, h5ds, h5f, h5fd, h5g, h5r, h5s, h5t, h5p, h5z
ImportError: cannot import name h5a

Did the patch make it in? Could this potentially be a compilation
issue on my side? The symbols in *.so all seem to resolve correctly,
but it could certainly be user error.

>
>> This seems similar to the question a few posts back about 10.8, where
>> somebody was seeing the same 'cannot import name _errors' and the
>> answer was to not use the system python -- but here I am not using system
>> python and it works for older python versions. So it may or not be related.
>
> The "cannot import name _errors" unfortunately can mean many things;
> it's the first module h5py tries to import, so you get this for a wide
> variety of compilation errors, linker errors, etc.

Here I don't see it unless I attempt to import "h5py.h5a" twice, which
I assume is a side-effect of the partial import.

>>> import h5py.h5a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mturk/yt-x86_64-py3/lib/python3.3/site-packages/h5py/__init__.py",
line 7, in <module>
from h5py import h5a, h5d, h5ds, h5f, h5fd, h5g, h5r, h5s, h5t, h5p, h5z
ImportError: cannot import name h5a
>>> import h5py.h5a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mturk/yt-x86_64-py3/lib/python3.3/site-packages/h5py/__init__.py",
line 1, in <module>
from h5py import _errors
ImportError: cannot import name _errors

Any suggestions on how to debug or fix this?

Thanks very much,

Matt

>
>> Also -- why is there no __version__ string for h5py?
>
> I had always thought of it being for SVN/CVS per-file versioning. PEP
> 396 suggests otherwise. I'm certainly happy to include it if people
> want. For the moment you can always get the full version string as
> h5py.version.version.
>
> Andrew
>
> --
> You received this message because you are subscribed to the Google Groups "h5py" group.
> To post to this group, send email to h5...@googlegroups.com.
> To unsubscribe from this group, send email to h5py+uns...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/h5py?hl=en.
>

Andrew Collette

unread,
Mar 14, 2013, 12:33:29 PM3/14/13
to h5...@googlegroups.com
Hi Matt,

> Did the patch make it in? Could this potentially be a compilation
> issue on my side? The symbols in *.so all seem to resolve correctly,
> but it could certainly be user error.

Yes, that patch was applied; looking at __init__.py I see the absolute
imports as they should be. I can also run the test suite for master
(there's one failed test I'm still trying to track down); what happens
if you do "python setup.py test" after building?

> Any suggestions on how to debug or fix this?

Trying to reproduce this just now I had a hell of a time because I
accidentally had PYTHONPATH set to a directory with another build of
h5py for Python 2.7. The result was much the same: the _errors import
failed, as it's the first line in __init__.py. You might double-check
your environment.

You could also try running python with the -v option (or -vv) to see
exactly what's going on. I have limited experience with the internals
of the python import process but am happy to look at the log if you
want.

Andrew

Andrew Collette

unread,
Mar 14, 2013, 12:42:37 PM3/14/13
to h5...@googlegroups.com
> Yes, that patch was applied; looking at __init__.py I see the absolute
> imports as they should be. I can also run the test suite for master
> (there's one failed test I'm still trying to track down); what happens
> if you do "python setup.py test" after building?

Looks like I spoke too soon: this is the relevant bug report:

https://github.com/h5py/h5py/issues/251

h5t.pyx still has the erroneous "import _conv" but for whatever reason
it works fine on my end. I agree it should be fixed, but there may be
some version-related hiccup that's causing our builds to differ.

What exact version of Python and cython do you have? I have:

Python 3.3.0
Cython.__version__ '0.18'

Andrew

Matthew Turk

unread,
Mar 14, 2013, 2:17:41 PM3/14/13
to h5...@googlegroups.com
Hi Andrew,
Ah! That did it. I'm on Cython 0.17.1. Changing all of these
instances fixed it:

import _conv
import _objects

This showed up in most of the h5[a-z].pyx files. Now I'm able to
import just fine. I can try to submit a PR to this effect, if it
would help. Thanks!

-Matt

>
> --
> You received this message because you are subscribed to the Google Groups "h5py" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to h5py+uns...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Andrew Collette

unread,
Mar 14, 2013, 3:42:38 PM3/14/13
to h5...@googlegroups.com
Hi Matt,

> Ah! That did it. I'm on Cython 0.17.1. Changing all of these
> instances fixed it:
>
> import _conv
> import _objects
>
> This showed up in most of the h5[a-z].pyx files. Now I'm able to
> import just fine. I can try to submit a PR to this effect, if it
> would help. Thanks!

Yes, absolutely that would help! You can base it on master if you
want, since we don't support Python 3.3 on the 2.1 branch.

Andrew
Reply all
Reply to author
Forward
0 new messages