重複の可能性:
OS X への h5py のインストール
OS X Lion 10.7.3 Macbook Pro で h5py を動作させようとしています。以前は機能していましたが、どういうわけかアンインストールされ、再度インストールできません。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 グループ Web サイト ( 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 ライブラリの両方を削除し、それらを数回再インストールしました (両方とも pip と easy_install を使用して h5py を自分でコンパイルしました) が、それは役に立たなかったようです。
このコマンドを使用して作成したばかりのビルドを使用して、h5py もインストールしました。
python setup.py build --hdf5=../hdf5-1.8.8/hdf5
また、numpy と scipy のインストールを最新バージョンに更新しました。