You will need to export the HDF5_DIR environment variable first. Run: $ export HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.1/ $ pip install --no-binary=h5py h5py