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

Building master fails on Ubuntu 16.10 for HDF4

Open timburgess opened this issue 8 years ago • 1 comments

The system I'm installing to is Ubuntu 16.10 (pretty much a stock desktop install)

I've installed the Ubuntu packaged hdf4 and hdf5 packages. dpkg -l |grep hdf gives me:

hdf5-helpers                                 1.8.16+docs-8 
libhdf4-0-alt                                       4.2.12-1
libhdf4-alt-dev                                    4.2.12-1
libhdf5-10:amd64                          1.8.16+docs-8
libhdf5-cpp-11:amd64                   1.8.16+docs-8
libhdf5-dev                                    1.8.16+docs-8
libhdf5-serial-dev                          1.8.16+docs-8

I've installed hdf4 as I want to use python-netCDF4 to also read hdf4.

As the install page says For netCDF < 4.4.1, HDF5 version 1.8.x is recommended, I've grabbed netcdf4 4.4.0 and done:

CPPFLAGS="-I/usr/include/hdf5/serial -I/usr/include/hdf" LDFLAGS=-L/usr/lib/x86_64-linux-gnu/hdf5/serial/ ./configure --prefix=/usr/local --enable-hdf4 --enable-netcdf-4 --enable-shared make sudo make install make test

The test passes without error.

I have Cython 0.25.2 installed.

nc-config --cflags shows:

-I/usr/local/include -I/usr/include/hdf5/serial -I/usr/include/hdf

I've then cloned the netcdf4-python github repo and doing:

python3 setup.py build, I get:

netCDF4/_netCDF4.c:84236:34: error: ‘NC_FILL_DOUBLE’ undeclared (first use in this function)
   __pyx_t_1 = PyFloat_FromDouble(NC_FILL_DOUBLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error)
                                  ^~~~~~~~~~~~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

So it appears that the netcdf header is not being found.

I've then edited setup.cfg to:

use_ncconfig=False netCDF4_dir = /usr/local HDF5_dir = /usr/include/hdf5/serial hdf4_libdir = /usr/lib hdf4_incdir = /usr/include/hdf

The HDF4-alt package installs headers to /usr/include/hdf and libs to /usr/lib according to the HDF4 package contents

python3 setup.py build now builds. sudo python3 setup.py install installs but on trying to read an HDF4 file, I get:

  File "netCDF4/_netCDF4.pyx", line 1848, in netCDF4._netCDF4.Dataset.__init__ (netCDF4/_netCDF4.c:13971)
OSError: NetCDF: Unknown file format

Am I doing anything wrong?

timburgess avatar Dec 19 '16 07:12 timburgess

Perhaps the C library did not actually build with hdf4 support? Check the output of configure to make sure the hdf4 library and headers were detected.

Also, I don't think all hdf4 files can be read - only the ones using the 'scientific dataset' API.

jswhit avatar Dec 19 '16 15:12 jswhit