netcdf4-python icon indicating copy to clipboard operation
netcdf4-python copied to clipboard

HDF Error on file write when NetCDF is installed with `pip install`

Open fmaussion opened this issue 6 years ago • 4 comments

Note sure if this of interest to you, or if this is a problem inherent to pip wheels, but: I can't get NetCDF4 to work with pip install on a Debian machine. Writing data to a file exits with an HDF Error:

~/checkouts/readthedocs.org/user_builds/oggmcontrib/envs/latest/lib/python3.7/site-packages/oggm/utils/_workflow.py in create_gridded_ncdf_file(self, fname)
   1971         v.long_name = 'x coordinate of projection'
   1972         v.standard_name = 'projection_x_coordinate'
-> 1973         v[:] = x
   1974 
   1975         v = nc.createVariable('y', 'f4', ('y',), zlib=True)

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable.__setitem__()
netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable._put()
netCDF4/_netCDF4.pyx in netCDF4._netCDF4._ensure_nc_success()
RuntimeError: NetCDF: HDF error

As a testbed to test several configurations, I used our ReadTheDocs builds. See e.g. one that fails: https://readthedocs.org/projects/oggmcontrib/builds/9502693/.

After several trial and error, I found a config that worked: pinning python to 3.5 and NetCDF4 to 1.3.1. Both on ReadTheDocs and on my local machine (relatively old Linux Mint with python 3.5), any other combination of higher python or NetCDF versions fail with the error above.

fmaussion avatar Aug 12 '19 12:08 fmaussion

I have a similar problem. Recent versions of Netcdf-4 crash with HDF Error in my code (e.g. https://github.com/StingraySoftware/HENDRICS/issues/72)

matteobachetti avatar Dec 11 '19 09:12 matteobachetti

What version of libnetcdf (netcdf-c) is installed on the Debian machine?

dopplershift avatar Dec 18 '19 03:12 dopplershift

I have the same problem. My system is Debian Stretch with python v3.8.1, hdf5 v1.10.6 and netCDF-c v4.7.3. The problem is solved when I install netCDF4-python from source (obtained with git clone) using "python3 setup.py install". The version of the software is 1.5.4

It is not clear to me if the problem is fixed because I have installed the module from source (instead of pip) or if you have fixed the problem in the source-code? If the latter is case than please can you release version 1.5.4?

rmvanhees avatar Feb 14 '20 12:02 rmvanhees

NetCDF4 to 1.3.1.

I met the same error as @fmaussion described. When I runned pip install netCDF4==1.3.1, there was some bug : ValueError: did not find HDF5 headers,how to fix it?

muyuuuu avatar Mar 13 '21 07:03 muyuuuu