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

3

11

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.

Myrick answered 5/1, 2022 at 4:57 Comment(0)
M
16

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 OR export HDF5_DIR=/opt/homebrew/opt/hdf5 (if hdf5 is installed in the "/opt/homebrew/opt/hdf5" location, you have to check it out first)
$ pip install --no-binary=h5py h5py

Note:- in the first command "1.12.0_4" is the version of hdfc installed in my system, you have to change it according to yours.

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
Myrick answered 5/1, 2022 at 5:8 Comment(4)
I still get a ERROR: Failed building wheel for h5pyOverhang
Just FYI. This solutions worked on MacOS 12.3 with M1 chip. Make sure you use the arch -arm64 even if the brew works w/o it, cause pip doesn't work.Ilona
export HDF5_DIR=$(brew --prefix hdf5) loooks like more stable solution for env var setupCircumpolar
This worked for me, without the -arch command, on MacOS 12.4 with M1.Scenic
F
2

After installing hdf5 try "export HDF5_DIR=/opt/homebrew/opt/hdf5"

Ref: https://github.com/h5py/h5py/issues/2035#issuecomment-1028226141

Forswear answered 14/2, 2022 at 10:19 Comment(0)
O
1

This works for me:

  1. Install brew (https://brew.sh/)
  2. brew install hdf5
  3. export HDF5_DIR=$(brew --prefix hdf5) (as @sgt pepper said)
  4. pip install --no-binary=h5py h5py
Optimism answered 15/1, 2023 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.