安装 TensorFlow 时,遇到一个依赖 h5py,这个包无论如何无法成功安装,报错无任何可用信息:
1 |
ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects |
这就很难办了,查看日志发现原来是没有针对 m1 的二进制包,自动进行编译了。但编译报错说找不到头文件:
1 2 3 4 5 |
./h5py/api_compat.h:27:10: fatal error: 'hdf5.h' file not found #include "hdf5.h" ^~~~~~~~ 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 |
于是使用 brew 安装缺少的库,搜索之下,还真有: brew install hdf5 ,安装后再次执行 h5py 的安装,还是一样的报错,显然还是找不到。
此时使用命令 find /opt -iname "*hdf5.h*" 查找,应该能找到 /opt/homebrew/include/hdf5.h 这个路径,使用以下命令添加相关环境变量:
1 2 |
export CPATH="/opt/homebrew/include/" export HDF5_DIR=/opt/homebrew/ |
再次执行命令安装 h5py: python3 -m pip install h5py
终于安装成功。
本文由 落格博客 原创撰写:落格博客 » macOS M1 Pro 安装 h5py
转载请保留出处和原文链接:https://www.logcg.com/archives/3548.html
Sorry I fixed this problem but now my issue is no more this error message. Now when I type the command find /opt -iname “*hdf5.h*”
I don’t have anything in return on my terminal. Just a new (base)MacBook-Pro….line to enter a new command
hi,
thanks for your help. I managed to install hdf5 with hombres but when I try running the command Find /opt -iname “*hdf5.h*”
I get this message find: /opt/cisco/anyconnect/temp/downloader: Permission denied
I don’t understand. I try doing it from other internet connection, and doing it while deactivating the Cisco VPN (also I don’t have Cisco app) but nothing seems to work.
Do you have any suggestion ?
Thank you
try prefix ur cmd with sudo
you need to run ‘brew install hdf5’ first
Iam getting this error after executing the cammand :
Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
To rerun under ARM use:
arch -arm64 brew install …
To install under x86_64, install Homebrew into /usr/local.
Upon trying the command again:
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
make sure ur terminal running on arm mode instead of Rosetta. And delete the Homebrew thing under /usr/local, arm version of brew installed at /opt/homebrew
I think u need to clean out your env path settings, the intel env confusing them.
that helped, thanks!
I did as you instructed but, still get:
ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects
The above error is generated after running this command for the second time: python3 -m pip install h5py
Did you try find /opt -iname "*hdf5.h*"
see if there any results like /opt/homebrew/include/hdf5.h
the main theory is h5py requiring hdf5, but it cant build itself, we have to install the library manually, then install h5py.
You saved my ass!