ERROR:Failed building wheel for h5pyFailed to build h5pyERROR:Could not build wheels for h5py,which is required toinstall pyproject.toml-basedprojects

I'm getting this error when I'm running the following command to install tensorflow.

python3 -m pip install tensorflow-macos
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

I tired to install this wheel manually, from the official link (https://pypi.org/project/h5py/#files), it got installed properly but I'm still getting the same error.

I'm facing the above issue in Mac Book M1 chip.


The official doc to use brew install.

$ brew install hdf5

If the above command gives you rosetta 2 issue, then run:-

arch -arm64 brew install hdf5   

Once, the h5py installation is done, run following 2 commands:-

$ export HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.0_4
$ pip install --no-binary=h5py h5py

If you are getting the aforementioned error implies you must be using poetry.

Finally run:-

poetry install

We are running the above command, In case poetry wants to update anything.

Once we run poetry install, it might update existing libraries or download new libraries.

So we have to update poetry.lock file as well.

poetry lock