我有一台M1 MacBook。我使用pyenv安装了Python 3.9.1,并拥有pip3版本21.0.1。
我已经安装了Homebrew和hdf5 1.12.0_1,通过
brew install hdf5
命令进行安装。
当我输入以下命令时: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
文件,因此我尝试在安装h5py之前运行export LDFLAGS="-L/opt/homebrew/opt/hdf5/lib"
和 export CPPFLAGS="-L/opt/homebrew/opt/hdf5/include"
,但是它们并没有起作用。
请问如何安装h5py?
实际上我是要安装h5py来满足安装Keras的要求。
谢谢!
sudo port install package_name
。祝你好运。 - kcw78