【问题标题】:How to install h5py (needed for Keras) on MacOS with M1?如何使用 M1 在 MacOS 上安装 h5py(Keras 需要)?
【发布时间】:2021-06-18 20:17:56
【问题描述】:

我有一台 M1 MacBook。我已经使用 pyenv 安装了 python 3.9.1,并且有 pip3 版本 21.0.1。 我已经通过brew install hdf5 安装了自制软件和 hdf5 1.12.0_1。

当我输入时

pip3 install h5py

我得到错误:

Requirement already satisfied: numpy>=1.19.3 in /Users/.../.pyenv/versions/3.9.1/lib/python3.9/site-packages (from h5py) (1.20.0)
Building wheels for collected packages: h5py
  Building wheel for h5py (PEP 517) ... error

  Loading library to get build settings and version: libhdf5.dylib
  error: Unable to load dependency HDF5, make sure HDF5 is installed properly
  error: dlopen(libhdf5.dylib, 6): image not found
  ----------------------------------------
  ERROR: Failed building wheel for h5py

我看到/opt/homebrew/opt/hdf5/lib 中存在libhdf5.dylib,所以我事先尝试了export LDFLAGS="-L/opt/homebrew/opt/hdf5/lib"export CPPFLAGS="-L/opt/homebrew/opt/hdf5/include",但它们没有帮助。

如何安装 h5py?

我实际上是在安装 h5py 作为安装 Keras 的要求。

谢谢!

【问题讨论】:

  • 我不是 Mac 用户,所以帮助有限。但是,我看到了一个关于在 Mac M1 上安装 Python 包的类似问题。他没有使用 pip 来安装软件包。相反,他使用了 macports,如下所示:sudo port install package_name。祝你好运

标签: python keras hdf5 h5py apple-m1


【解决方案1】:

尝试使用 conda 安装 h5py。对我有用。

conda install h5py

【讨论】:

  • 简单直接的解决方案。适用于我的 Apple M1 Mac Mini。谢谢!
  • 使用 M1 在 MacBook 上工作
【解决方案2】:

这对我有用:

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2022-08-24
  • 2021-11-21
  • 2021-10-10
  • 2023-04-04
  • 1970-01-01
  • 2023-02-16
  • 1970-01-01
  • 2022-08-10
相关资源
最近更新 更多