Friday, April 19, 2013

How to install the h5py in mac?


MacOS X

MacPorts

If you are installing Python for the first time, we strongly recommend the use of MacPorts to install a full Python distribution. If you would like to do this, follow these instructions to get set up. Once you have your Python distribution installed, make sure all the dependencies for Hyperion are installed:
sudo port selfupdate
sudo port install py27-numpy py27-matplotlib py27-h5py py27-astropy
If this works, you are all set, and you can move on to the actual Hyperion installation instructions.

System/python.org Python

Numpy and Matplotlib

If you do not want to use MacPorts, the easiest way to install the two first dependencies is to download and install the MacOS X dmg files for NumPy and Matplotlib. Use the links at the top of this section to get the latest dmg files from the different websites. You can of course also install these from source, but this is beyond the scope of this documentation.
Note
If you get an error saying x can’t be installed on this disk. x requires Python 2.7 from www.python.org to install, then this means you are probably just using the system Python installation. Go to www.python.org and download the 2.7.2 version of Python, install, and try installing the packages again.
Check that the packages import correctly:
$ python
Python 2.7.2 (default, Jan 31 2012, 22:38:06)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import matplotlib
>>>
If any of the packages are incorrectly installed, they will not import cleanly as above.

h5py

Once Numpy and Matplotlib are installed, you will need to install h5py. First, you will need to install the HDF5 library. Note that for the Fortran code, you also need to install the HDF5 library, but here we need to create a clean installation without the fortran bindings, or else h5py will not install properly. Make sure that you perform the following installation in a different directory from before, to avoid overwriting any files.
To install the plain HDF5 library download the source code from the latest HDF5 downloads (choose the hdf5-x.x.x.tar.gz file), then expand the source code:
tar xvzf hdf5-x.x.x.tar.gz
cd hdf5-x.x.x
and carry out the installation:
./configure --prefix=/usr/local/hdf5
make
sudo make install
Now, download the latest h5py-x.x.x.tar.gz package from the h5py website, and do:
tar xvzf h5py-x.x.x.tar.gz
cd h5py-x.x.x
python setup.py build --api=18 --hdf5=/usr/local/hdf5
python setup.py install
Now, go back to your home directory, and check that h5py imports cleanly:
$ python
Python 2.7.2 (default, Jan 31 2012, 22:38:06)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import h5py
>>>

No comments:

Post a Comment