Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h5py raising on xr.show_versions() #3144

Closed
max-sixty opened this issue Jul 18, 2019 · 3 comments
Closed

h5py raising on xr.show_versions() #3144

max-sixty opened this issue Jul 18, 2019 · 3 comments

Comments

@max-sixty
Copy link
Collaborator

Any ideas why __hdf5libversion__ wouldn't be available? Shall I put a try / except around it?

In [4]: import xarray as xr

In [5]: xr.show_versions()
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/xarray/util/print_versions.py in netcdf_and_hdf5_versions()
     64     try:
---> 65         import netCDF4
     66         libhdf5_version = netCDF4.__hdf5libversion__

ModuleNotFoundError: No module named 'netCDF4'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-5-6f391305f2fe> in <module>
----> 1 xr.show_versions()

/usr/local/lib/python3.7/site-packages/xarray/util/print_versions.py in show_versions(file)
     78     sys_info = get_sys_info()
     79
---> 80     sys_info.extend(netcdf_and_hdf5_versions())
     81
     82     deps = [

/usr/local/lib/python3.7/site-packages/xarray/util/print_versions.py in netcdf_and_hdf5_versions()
     69         try:
     70             import h5py
---> 71             libhdf5_version = h5py.__hdf5libversion__
     72         except ImportError:
     73             pass

AttributeError: module 'h5py' has no attribute '__hdf5libversion__'

I check I'm on the latest h5py:

pip install h5py -U                                                                                                   Thu Jul 18 16:47:29 2019
Requirement already up-to-date: h5py in ./Library/Python/3.7/lib/python/site-packages (2.9.0)
Requirement already satisfied, skipping upgrade: numpy>=1.7 in /usr/local/lib/python3.7/site-packages (from h5py) (1.16.4)
Requirement already satisfied, skipping upgrade: six in ./Library/Python/3.7/lib/python/site-packages (from h5py) (1.12.0)
@shoyer
Copy link
Member

shoyer commented Jul 18, 2019

Hmm, now I'm not sure that line ever worked. I may just copied the variable from netCDF4.

It think it should be h5py.version.hdf5_version, which has been around in h5py for quite a while, e.g.,
https://github.com/h5py/h5py/blob/2.0.0/h5py/version.py#L8
https://github.com/h5py/h5py/blob/2.9.0/h5py/version.py#L39

But yes, let's catch AttributeError, too, just in case that changes in the future.

@max-sixty
Copy link
Collaborator Author

I think it must work under some setups, since it's tested. I changed and added a broader try / except

@shoyer
Copy link
Member

shoyer commented Jul 18, 2019

I don't think we have any CI configurations with h5py installed but not netCDF4.

@shoyer shoyer closed this as completed Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants