use h5py in plugin

I would like to use h5py in a Python plugin. When trying to import it, I’m getting

ERROR: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/Filters/Python/vtkPythonAlgorithm.cxx, line 112
vtkPythonAlgorithm (0x1a3d6e00): Failure when calling method: "ProcessRequest":

Traceback (most recent call last):
  File "/home/nschloe/software/paraview/ParaView-5.9.0-RC4-MPI-Linux-Python3.8-64bit/lib/python3.8/site-packages/vtkmodules/util/vtkAlgorithm.py", line 152, in ProcessRequest
    return vtkself.ProcessRequest(request, inInfo, outInfo)
  File "/home/nschloe/software/paraview/ParaView-5.9.0-RC4-MPI-Linux-Python3.8-64bit/lib/python3.8/site-packages/vtkmodules/util/vtkAlgorithm.py", line 198, in ProcessRequest
    return self.RequestData(request, inInfo, outInfo)
  File "/home/nschloe/.local/share/paraview/plugins/paraview-meshio-plugin.py", line 73, in RequestData
    mesh = meshio.read(self._filename, self._file_format)
  File "/home/nschloe/rcs/meshio/meshio/_helpers.py", line 69, in read
    return reader_map[file_format](filename)
  File "/home/nschloe/rcs/meshio/meshio/hmf/_hmf.py", line 11, in read
    import h5py
ModuleNotFoundError: No module named 'h5py'
ERROR: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/Common/ExecutionModel/vtkExecutive.cxx, line 753
vtkPVCompositeDataPipeline (0x1a446340): Algorithm vtkPythonAlgorithm(0x1a3d6e00) returned failure for request: vtkInformation (0x16727f60)
  Debug: Off
  Modified Time: 1937058
  Reference Count: 2
  Registered Events: (none)
  Request: REQUEST_DATA
  FROM_OUTPUT_PORT: 0
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0



ERROR: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/Filters/Python/vtkPythonAlgorithm.cxx, line 112
vtkPythonAlgorithm (0x16076140): Failure when calling method: "ProcessRequest":

Traceback (most recent call last):
  File "/home/nschloe/software/paraview/ParaView-5.9.0-RC4-MPI-Linux-Python3.8-64bit/lib/python3.8/site-packages/vtkmodules/util/vtkAlgorithm.py", line 152, in ProcessRequest
    return vtkself.ProcessRequest(request, inInfo, outInfo)
  File "/home/nschloe/software/paraview/ParaView-5.9.0-RC4-MPI-Linux-Python3.8-64bit/lib/python3.8/site-packages/vtkmodules/util/vtkAlgorithm.py", line 198, in ProcessRequest
    return self.RequestData(request, inInfo, outInfo)
  File "/home/nschloe/.local/share/paraview/plugins/paraview-meshio-plugin.py", line 73, in RequestData
    mesh = meshio.read(self._filename, self._file_format)
  File "/home/nschloe/rcs/meshio/meshio/_helpers.py", line 69, in read
    return reader_map[file_format](filename)
  File "/home/nschloe/rcs/meshio/meshio/hmf/_hmf.py", line 11, in read
    import h5py
ModuleNotFoundError: No module named 'h5py'
ERROR: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/Common/ExecutionModel/vtkExecutive.cxx, line 753
vtkPVCompositeDataPipeline (0x19f25d00): Algorithm vtkPythonAlgorithm(0x16076140) returned failure for request: vtkInformation (0x15f58550)
  Debug: Off
  Modified Time: 2190375
  Reference Count: 2
  Registered Events: (none)
  Request: REQUEST_DATA
  FROM_OUTPUT_PORT: 0
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0

Apparently, ParaView does not use the system Python installation (where h5py is available).

Any hints?

I used to run into this when ParaView was using Python 2 and would set my PYTHONPATH to point to the appropriate site-packages directory.

However, with Python 3 via ParaView 5.9.0, I’m having similar issues and am unable to overcome them.