For Python beginners¶
It can be a pain to install NumPy, HDF5, h5py, Cython and other dependencies.
If you’re just starting out, by far the easiest approach is to install h5py via
your package manager (
apt-get or similar), or by using one of the major
science-oriented Python distributions:
Installing on Windows¶
You will need:
- Python 2.6, 2.7, 3.2, 3.3 or 3.4 (from Python.org)
- NumPy 1.6.1 or newer
- The “six” Python 2/3 compatibility package
Download the installer from http://www.h5py.org and run it. HDF5 is included.
If you are using Anaconda, PythonXY or another non-Python.org distribution, you should instead install h5py via your distribution’s own pacakge manager.
Installing on Linux and Mac OS X¶
You will need:
- Python 2.6, 2.7, 3.2, 3.3, or 3.4 with development headers (
- HDF5 1.8.4 or newer, shared library version with development headers (
On Mac OS X, homebrew is a reliable way of getting Python, HDF5 and other dependencies set up. It is also safe to use h5py with the OS X system Python.
Install with pip¶
$ pip install h5py
All dependencies are installed automatically.
Running the test suite¶
With the tarball version of h5py:
$ python setup.py build $ python setup.py test
After installing h5py:
>>> import h5py >>> h5py.run_tests()
You can specify build options for h5py with the
configure option to
setup.py. Options may be given together or separately:
$ python setup.py configure --hdf5=/path/to/hdf5 $ python setup.py configure --hdf5-version=X.Y.Z $ python setup.py configure --mpi
--hdf5-version option is generally not needed, as h5py
auto-detects the installed version of HDF5 (even for custom locations).
Once set, build options apply to all future builds in the source directory.
You can reset to the defaults with the
$ python setup.py configure --reset
You can also configure h5py using environment variables. This is handy
when installing via
pip, as you don’t have direct access to setup.py:
$ HDF5_DIR=/path/to/hdf5 pip install h5py $ HDF5_VERSION=X.Y.Z pip install h5py
Here’s a list of all the configure options currently supported:
|Option||Via setup.py||Via environment variable|
|Custom path to HDF5||
|Force HDF5 version||
|Enable MPI mode||
Building against Parallel HDF5¶
If you just want to build with
mpicc, and don’t care about using Parallel
HDF5 features in h5py itself:
$ export CC=mpicc $ python setup.py install
If you want access to the full Parallel HDF5 feature set in h5py (Parallel HDF5), you will have to build in MPI mode. Right now this must be done with command-line options from the h5py tarball.
You will need a shared-library build of Parallel HDF5 (i.e. built with ./configure –enable-shared –enable-parallel).
To build in MPI mode, use the
--mpi option to
$ export CC=mpicc $ python setup.py configure --mpi $ python setup.py build
See also Parallel HDF5.