4

macOS M1 Pro install h5py

 2 years ago
source link: https://www.logcg.com/archives/3548.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
最近更新:10th 1月, 2022

安装 TensorFlow 时,遇到一个依赖 h5py,这个包无论如何无法成功安装,报错无任何可用信息:

ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects

这就很难办了,查看日志发现原来是没有针对 m1 的二进制包,自动进行编译了。但编译报错说找不到头文件:

  ./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 这个路径,使用以下命令添加相关环境变量:

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

About the Author

9199db428730d8ac5dd90f8c180f8713?s=64&d=mm&r=pg

落格博客

如非声明,本人所著文章均为原创手打,转载请注明本页面链接和我的名字。

Comments

  1. that helped, thanks!

  2. 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

    1. 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.

  3. You saved my ass!

发表评论 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

评论 *

显示名称 *

电子邮箱地址 *

网站地址

在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次评论时使用。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK