Possible Duplicate:
Installing h5py on OS X
I am trying to get h5py to work on my OS X Lion 10.7.3 Macbook Pro. It has worked before but somehow it got uninstalled and I can't get it installed again. It seems it has to do with installing XCode 4.3, but I'm not sure.
When importing h5py, I get the following error:
>>> 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
I guess it has something to do with the HDF5-library. It was not yet installed, so I installed it first using
brew install hdf5
This gave no errors. But the following warning at the end. which I guess is important:
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)
I'm not 100% sure what this means, but I guess this library is compiled for an i386 architecture, there however more files in this directory it does not complain about:
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
Later I also compiled the source myself, downloaded from the HDF5 group-website (http://www.hdfgroup.org/HDF5/). Using the following configure-line, to make sure it makes shared libraries I added --enable-shared and disabled 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
I have removed both h5py and the hdf5 library and reinstalled them a few times (both compiling h5py myself, as using pip and easy_install), but that did not seem to help.
I also installed h5py using the build I just made using this command:
python setup.py build --hdf5=../hdf5-1.8.8/hdf5
I also updated my numpy and scipy installations to the latest versions.
On OSX/MacOS, h5py can be installed via Homebrew, Macports, or Fink. The current state of h5py in various Linux Distributions can be seen at https://pkgs.org/download/python-h5py, and can be installed via the package manager.
The h5py package is a Pythonic interface to the HDF5 binary data format. HDF5 lets you store huge amounts of numerical data, and easily manipulate that data from NumPy. For example, you can slice into multi-terabyte datasets stored on disk, as if they were real NumPy arrays.
Search for the HDF5 library in the ubuntu package repository. The command will show the packages relating to hdf5. install the relevant package to you. sudo apt-get install package-name.
From a clean install of Mac OS X Lion, what I had to do is the following:
xcode-select ...
)Then I could:
$ brew install hdf5
It didn't link properly, because my /usr/local/lib
wasn't writable. Check brew doctor
to see if there are any unlinked packages:
$ brew doctor
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built.
hdf5
szip
So I made the dir writable and used
$ brew link hdf5
$ brew link szip
Then I could do
$ sudo pip install h5py
And presto.
>>> import h5py
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With