Cannot build h5py for python 3.11 with HDF5 1.14.11

Hello,

I’m trying to build h5py from source with python3 setup.py build, which fails with:

Error compiling Cython file:
------------------------------------------------------------
...

info.name = 'fileobj'
info.maxaddr = libc.stdint.SIZE_MAX - 1
info.fc_degree = H5F_CLOSE_WEAK
info.fapl_size = sizeof(PyObject *)
info.fapl_get = <void *(*)(H5FD_t *)>H5FD_fileobj_fapl_get
                ^
------------------------------------------------------------

h5py/h5fd.pyx:198:16: Cannot assign type 'void *(*)(H5FD_t *) except *' to 'void *(*)(H5FD_t *) noexcept'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void *(H5FD_t *) except *'.

There are several such Error compiling Cython file triggered. Please help.

What version of cython are you using? See: build issue when using cython 3.0 · Issue #2268 · h5py/h5py · GitHub.

Aleksandar

I’m using cython 3.0.2. From the issue you sent, I take it that this is still an open issue?

Yes, it is still an open issue. I advise to avoid installing h5py from source if possible. If you need to install from source, remove first the cython package then try the pip command as described in the h5py documentation.

Aleksandar

I would like to install h5py from source because I want h5py to use the same HDF5 library as my C and Fortran codes. I don’t know if that’s the case with h5py, but in installing other python modules with pip install, I’ve seen that they bring their own dependencies with them. So for example pip install h5py might bring its own libhdf5 binary. I’d like to avoid that.

In the end I downgraded cython to a version before 3 and was able to install h5py from source.

Yes, that command will install h5py’s own libhdf5. But at the documentation I linked there is a pip command that does install from source and hence will use the libhdf5 you want. My point was to use pip so it can handle the cython dependency correctly because h5py’s code does not work with any Cython 3.x yet. You probably installed Cython prior to building h5py and used a wrong version.

Aleksandar

1 Like