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

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

当我运行使用以下命令安装 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

我厌倦了从官方 link (https://pypi.org/project/h5py/#files) 手动安装这个轮子,它安装正确但我仍然遇到同样的错误。

我在 Mac Book M1 芯片中遇到上述问题。

official doc使用brew install。

$ brew install hdf5

如果上面的命令给你 rosetta 2 问题,那么 运行:-

arch -arm64 brew install hdf5   

一次,h5py 安装完成,运行 以下 2 个命令:-

$ 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

注意:-第一条命令“1.12.0_4”是我系统安装的hdfc的版本,你要根据自己的改。

如果您遇到上述错误,则说明您一定是在使用诗歌。

最后运行:-

poetry install

我们正在 运行 执行上述命令,以防 poetry 想要更新任何内容。

一旦我们 运行 poetry install,它可能会更新现有库或下载新库。

因此我们还必须更新 poetry.lock 文件。

poetry lock

安装 hdf5 后尝试“导出 HDF5_DIR=/opt/homebrew/opt/hdf5”

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