[英]How to install h5py (needed for Keras) on MacOS with M1?
I have an M1 MacBook.我有一台 M1 MacBook。 I have installed python 3.9.1 using pyenv, and have pip3 version 21.0.1.
我已经使用 pyenv 安装了 python 3.9.1,并且 pip3 版本为 21.0.1。 I have installed homebrew and hdf5 1.12.0_1 via
brew install hdf5
.我已经通过
brew install hdf5
。
When I type当我输入
pip3 install h5py
I get the error:我得到错误:
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
I saw that libhdf5.dylib
is present in /opt/homebrew/opt/hdf5/lib
, so I tried export LDFLAGS="-L/opt/homebrew/opt/hdf5/lib"
and export CPPFLAGS="-L/opt/homebrew/opt/hdf5/include"
beforehand but they don't help.我看到
libhdf5.dylib
存在于/opt/homebrew/opt/hdf5/lib
,所以我尝试了export LDFLAGS="-L/opt/homebrew/opt/hdf5/lib"
和export CPPFLAGS="-L/opt/homebrew/opt/hdf5/include"
事先但他们没有帮助。
How can I install h5py?如何安装 h5py?
I am actually installing h5py as a requirement to install Keras.我实际上是安装 h5py 作为安装 Keras 的要求。
Thanks!谢谢!
This works for me:这对我有用:
$ brew install hdf5
$ export HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.0_4
$ pip install --no-binary=h5py h5py
Try to install h5py using conda.尝试使用 conda 安装 h5py。 Works for me.
为我工作。
conda install h5py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.