Installation issue with h5py

Dear community,
I followed the references in the site in order to install FEniCSx through ubuntu. I’m able to run script both in 3D and 2D with mesh created in python. I can’t run script in which the mesh is created and imported. There’s no errors in the script, in fact i’m able to run with an editor like pycharm, but when i run in ubuntu i get the following error and I’m stuck. Thanks for any help

How did you install

  1. FEniCSx (through apt-Get?)
  2. h5py (through pip?)

If you installed h5py through pip3 you need to make sure you do not install another binary, i.e.
pip3 install —no-binary=h5py h5py as DOLFINx already depends on hdf5.

Yes, FEniCSx is installed through apt-get, for h5py i follow this documentation but nothing works, always the same error appear. Installation — h5py 3.7.0 documentation

Any suggestion?

You Need to first uninstall h5py, as you now have it installed with wheels, as noted in: Installation — h5py 3.10.0 documentation
Then you should call the command

Could also just use apt and not use pip after uninstalling, in order to avoid the clash

apt-get install python3-h5py python3-h5py-mpi
1 Like

Unfortunately there’s no way to install. I’ll post the message error, I’m a new user of ubuntu but it seems no way solution :face_with_spiral_eyes:

As it says here, you already have h5py installed. You need to uninstall the current version

pip3 uninstall h5py

prior to trying to reinstall it with no binary.

I did it. But the error is always:


a

Instead of putting in pictures of error messages, it would be better if you could format the input/output of terminal messages as:

```bash
Insert command here
```

In the last picture you supplied, it seems like you have sucessfully uninstalled h5py.
What happens if you now try to re-install it?

simulator@DESKTOP-CL4ID9R:~$ pip3 install --no-binary=h5py h5py
Defaulting to user installation because normal site-packages is not writeable
Collecting h5py
  Using cached h5py-3.7.0.tar.gz (392 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.14.5 in ./.local/lib/python3.8/site-packages (from h5py) (1.23.1)
Building wheels for collected packages: h5py
  Building wheel for h5py (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for h5py (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [130 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/h5py
      copying h5py/h5py_warnings.py -> build/lib.linux-x86_64-cpython-38/h5py
      copying h5py/version.py -> build/lib.linux-x86_64-cpython-38/h5py
      copying h5py/ipy_completer.py -> build/lib.linux-x86_64-cpython-38/h5py
      copying h5py/__init__.py -> build/lib.linux-x86_64-cpython-38/h5py
      creating build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/datatype.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/selections.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/group.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/vds.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/base.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/dims.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/files.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/dataset.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/attrs.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/__init__.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/compat.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/selections2.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      copying h5py/_hl/filters.py -> build/lib.linux-x86_64-cpython-38/h5py/_hl
      creating build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_dataset_swmr.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_dataset.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_file.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_attribute_create.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_dims_dimensionproxy.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_slicing.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_datatype.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_dtype.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_file2.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_filters.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_objects.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_file_alignment.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_h5f.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_h5d_direct_chunk.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_dataset_getitem.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_base.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/common.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/conftest.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_attrs.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_h5p.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_h5o.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_selections.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_completions.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_errors.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_h5.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_dimension_scales.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_attrs_data.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_group.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_big_endian_file.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_h5pl.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_h5t.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/test_file_image.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      copying h5py/tests/__init__.py -> build/lib.linux-x86_64-cpython-38/h5py/tests
      creating build/lib.linux-x86_64-cpython-38/h5py/tests/data_files
      copying h5py/tests/data_files/__init__.py -> build/lib.linux-x86_64-cpython-38/h5py/tests/data_files
      creating build/lib.linux-x86_64-cpython-38/h5py/tests/test_vds
      copying h5py/tests/test_vds/test_highlevel_vds.py -> build/lib.linux-x86_64-cpython-38/h5py/tests/test_vds
      copying h5py/tests/test_vds/test_lowlevel_vds.py -> build/lib.linux-x86_64-cpython-38/h5py/tests/test_vds
      copying h5py/tests/test_vds/test_virtual_source.py -> build/lib.linux-x86_64-cpython-38/h5py/tests/test_vds
      copying h5py/tests/test_vds/__init__.py -> build/lib.linux-x86_64-cpython-38/h5py/tests/test_vds
      copying h5py/tests/data_files/vlen_string_dset.h5 -> build/lib.linux-x86_64-cpython-38/h5py/tests/data_files
      copying h5py/tests/data_files/vlen_string_dset_utc.h5 -> build/lib.linux-x86_64-cpython-38/h5py/tests/data_files
      copying h5py/tests/data_files/vlen_string_s390x.h5 -> build/lib.linux-x86_64-cpython-38/h5py/tests/data_files
      running build_ext
      Loading library to get build settings and version: /usr/lib/x86_64-linux-gnu/hdf5/openmpi/libhdf5.so
      ********************************************************************************
                             Summary of the h5py configuration

      HDF5 include dirs: [
        '/usr/include/openmpi'
        '/usr/include/hdf5/openmpi'
      ]
      HDF5 library dirs: [
        '/usr/lib/x86_64-linux-gnu/hdf5/openmpi'
        '/usr/lib/openmpi/lib'
      ]
           HDF5 Version: (1, 10, 4)
            MPI Enabled: False
       ROS3 VFD Enabled: False
      DIRECT VFD Enabled: False
       Rebuild Required: True

      ********************************************************************************
      Executing api_gen rebuild of defs
      Updated /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/config.pxi
      Executing cythonize()
      [ 1/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/_conv.pyx
      [ 2/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/_errors.pyx
      [ 3/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/_objects.pyx
      [ 4/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/_proxy.pyx
      [ 5/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/_selector.pyx
      [ 6/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/defs.pyx
      [ 7/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5.pyx
      [ 8/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5a.pyx
      [ 9/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5ac.pyx
      [10/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5d.pyx
      [11/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5ds.pyx
      [12/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5f.pyx
      [13/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5fd.pyx
      [14/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5g.pyx
      [15/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5i.pyx
      [16/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5l.pyx
      [17/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5o.pyx
      [18/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5p.pyx
      [19/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5pl.pyx
      [20/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5r.pyx
      [21/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5s.pyx
      [22/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5t.pyx
      [23/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/h5z.pyx
      [24/24] Cythonizing /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/utils.pyx
      building 'h5py.defs' extension
      creating build/temp.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/tmp
      creating build/temp.linux-x86_64-cpython-38/tmp/pip-install-bqu6x3ax
      creating build/temp.linux-x86_64-cpython-38/tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5
      creating build/temp.linux-x86_64-cpython-38/tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DH5_USE_18_API -DNPY_NO_DEPRECATED_API=0 -I./h5py -I/usr/include/openmpi -I/usr/include/hdf5/openmpi -I/tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/lzf -I/tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/lzf/lzf -I/tmp/pip-build-env-_pqefzyh/overlay/lib/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/defs.c -o build/temp.linux-x86_64-cpython-38/tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/defs.o
      In file included from /usr/include/hdf5/openmpi/hdf5.h:22,
                       from /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/api_compat.h:27,
                       from /tmp/pip-install-bqu6x3ax/h5py_a7dd5fe2c98e42768689ec1d3af25ff5/h5py/defs.c:803:
      /usr/include/hdf5/openmpi/H5public.h:60:13: fatal error: mpi.h: No such file or directory
         60 | #   include <mpi.h>
            |             ^~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for h5py
Failed to build h5py
ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects
simulator@DESKTOP-CL4ID9R:~$

This is the complete output message.

Could you try with:

HDF5_MPI="ON"  pip3 install --no-cache-dir --no-binary=h5py h5py --upgrade

There are also several suggestions at: c++ - fatal error: mpi.h: No such file or directory #include <mpi.h> - Stack Overflow

It gives the same error. I succesfully installed

sudo apt install libopenmpi-dev
pip install mpi4py

then i run

HDF5_MPI="ON"  pip3 install --no-cache-dir --no-binary=h5py h5py --upgrade

and i got the same error.

This solved the problem in ubuntu 22.04.1 after reinstalling all packages and dependencies. Thanks a lot

Looks like you had an old version of Ubuntu. python3-h5py on its own will have to do on older releases where python3-h5py-mpi is not available. Glad you found ubuntu 22.04. Installation is usually simpler with the most recent release.

1 Like