【发布时间】:2012-04-10 00:48:06
【问题描述】:
我正在尝试让 h5py 在我的 OS X Lion 10.7.3 Macbook Pro 上运行。它以前工作过,但不知何故被卸载了,我无法再次安装它。似乎与安装 XCode 4.3 有关,但我不确定。
导入h5py时出现如下错误:
>>> import h5py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/h5py/__init__.py", line 1, in <module>
from h5py import _errors
ImportError: dlopen(/Library/Python/2.7/site-packages/h5py/_errors.so, 2): Symbol not found: _H5E_ALREADYEXISTS_g
Referenced from: /Library/Python/2.7/site-packages/h5py/_errors.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/h5py/_errors.so
我猜这与 HDF5 库有关。它还没有安装,所以我先用它安装了它
brew install hdf5
这没有出错。但最后会出现以下警告。我想这很重要:
ld: warning: ignoring file ../hdf5-1.8.8/hdf5/lib/libhdf5.a,
file was built for archive which is not the architecture being linked (i386)
我不是 100% 确定这意味着什么,但我猜这个库是为 i386 架构编译的,但是在这个目录中有更多文件并没有抱怨:
libhdf5.la
libhdf5.dylib -> libhdf5.7.dylib
libhdf5.7.dylib
libhdf5.settings
libhdf5.a
libhdf5_hl.la
libhdf5_hl.dylib -> libhdf5_hl.7.dylib
libhdf5_hl.a
libhdf5_hl.7.dylib
后来我自己也编译了源码,从 HDF5 群网站 (http://www.hdfgroup.org/HDF5/) 下载。使用以下配置行,以确保它创建共享库,我添加了 --enable-shared 并禁用了 fortran:
./configure --with-zlib=/usr/local --disable-fortran
--prefix=/usr/local/ --target=x86_64-apple-darwin
-build=x86_64-apple-darwin --host=x86_64-apple-darwin
--enable-shared --disable-production
我已经删除了 h5py 和 hdf5 库并重新安装了几次(都自己编译 h5py,如使用 pip 和 easy_install),但这似乎没有帮助。
我还使用我刚刚使用此命令创建的构建安装了 h5py:
python setup.py build --hdf5=../hdf5-1.8.8/hdf5
我还将我的 numpy 和 scipy 安装更新到了最新版本。
【问题讨论】:
标签: python compilation hdf5 h5py