简体   繁体   中英

Can not install pyhdf on ubuntu 13.04

When I try to install pyhdf, this error happens:

sudo easy_install -f pyhdf-0.8.3.tar.gz pyhdf
Searching for pyhdf
Best match: pyhdf 0.8.3
Processing pyhdf-0.8.3.tar.gz
Writing /tmp/easy_install-Q0FIMR/pyhdf-0.8.3/setup.cfg
Running pyhdf-0.8.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Q0FIMR/pyhdf-0.8.3/egg-dist-tmp-wXq_6K
pyhdf/hdfext_wrap.c: In function ‘SWIG_Python_AddErrorMsg’:
pyhdf/hdfext_wrap.c:859:5: warning: format not a string literal and no format arguments [-Wformat-security]
pyhdf/hdfext_wrap.c: At top level:
pyhdf/hdfext_wrap.c:3048:17: fatal error: hdf.h: No such file or directory
compilation terminated.
pyhdf/hdfext_wrap.c: In function ‘SWIG_Python_AddErrorMsg’:
pyhdf/hdfext_wrap.c:859:5: warning: format not a string literal and no format arguments [-Wformat-security]
pyhdf/hdfext_wrap.c: At top level:
pyhdf/hdfext_wrap.c:3048:17: fatal error: hdf.h: No such file or directory
compilation terminated.
error: Setup script exited with error: Command "x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -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
/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py:252: RuntimeWarning: Parent module 'numpy.distutils' not found while handling absolute import
  from numpy.distutils import log

Any idea what is wrong? Thank you.

You probably need to install libhdf4-dev package.

And instead of using sudo to install packages into your system, spend some time to read about virtualenv .

Even with libhdf4-dev package you can encounter the problem with missing hdf.h file(I did). It seems that code setup.py (in the installation archive) does not properly handle the environment variable which specifies where the HDF4 library is.

I solved the problem by following the step-by-step instruction of http://pysclint.sourceforge.net/pyhdf/install.html but you must add in the command line your hdf library instead of exporting it:

INCLUDE_DIRS=/usr/include/hdf/  [note it may be different in your system ]

sudo python setup.py install -i $INCLUDE_DIRS

Same problem for the NOSZIP variable if you don't have/want szlib, but here I modified setup.py on line 29:

szip_installed=False

Then installation works fine.

要解决此问题,您首先需要安装hdf开发包。

sudo apt-get install libhdf4-dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM