Install pyhdf error: hdf.h: No such file or directory
<p>I want to install <code>pyhdf</code> to read hdf4 files in python on ubuntu, and I downloaded from <a href="https://sourceforge.net/projects/pysclint/files/pyhdf/" rel="nofollow">https://sourceforge.net/projects/pysclint/files/pyhdf/</a>,<code>pyhdf-0.8.3.tar.gz</code>, but when I run <code>python setup.py install</code> on ubuntu, it shows </p>

<pre><code>running install
running bdist_egg
running egg_info
running build_src
build_src
building extension "pyhdf._hdfext" sources
build_src: building npy-pkg config files
writing pyhdf.egg-info/PKG-INFO
writing top-level names to pyhdf.egg-info/top_level.txt
writing dependency_links to pyhdf.egg-info/dependency_links.txt
reading manifest file 'pyhdf.egg-info/SOURCES.txt'
writing manifest file 'pyhdf.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
building 'pyhdf._hdfext' extension
compiling C sources
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC

compile options: '-I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
x86_64-linux-gnu-gcc: pyhdf/hdfext_wrap.c
pyhdf/hdfext_wrap.c: In function âSWIG_Python_AddErrorMsgâ:
pyhdf/hdfext_wrap.c:859:5: error: format not a string literal and no format arguments [-Werror=format-security]
     PyErr_Format(PyExc_RuntimeError, mesg);
     ^
pyhdf/hdfext_wrap.c: At top level:
pyhdf/hdfext_wrap.c:3048:17: fatal error: hdf.h: No such file or directory
cc1: some warnings being treated as errors
compilation terminated.
pyhdf/hdfext_wrap.c: In function âSWIG_Python_AddErrorMsgâ:
pyhdf/hdfext_wrap.c:859:5: error: format not a string literal and no format arguments [-Werror=format-security]
     PyErr_Format(PyExc_RuntimeError, mesg);
     ^
pyhdf/hdfext_wrap.c: At top level:
pyhdf/hdfext_wrap.c:3048:17: fatal error: hdf.h: No such file or directory
cc1: some warnings being treated as errors
compilation terminated.
error: Command "x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c pyhdf/hdfext_wrap.c -o build/temp.linux-x86_64-2.7/pyhdf/hdfext_wrap.o" failed with exit status 1
</code></pre>

<p>How to fix it?</p>

<p>Well finally I am answering my own question now...For people who want to install python-hdf4 on ubuntu.</p>

<p>Firstly you need to install the hdf4 and then the python-hdf4.</p>

<p>Hdf4 could be downloaded from <a href="https://www.hdfgroup.org/products/hdf4/" rel="nofollow">https://www.hdfgroup.org/products/hdf4/</a>, and then <code>unzip</code> the file using <code>tar xvf ...</code>, <code>cd</code> to the file and <code>/.configure</code>, if you do not need fortran then do <code>./configure --disable-fortran</code>, and it shoule be configured, and then <code>make</code>, <code>make check</code>, <code>make install</code> step by step, HDF4 should be installed succesfully.</p>

<p>And the next thing is simple, download python-hdf4 from <a href="https://pypi.python.org/pypi/python-hdf4" rel="nofollow">https://pypi.python.org/pypi/python-hdf4</a> and then cd to the file, <code>python setup.py install</code>, done!</p>

python pyhdf