Python 无法在ubuntu 13.04上安装pyhdf

Python 无法在ubuntu 13.04上安装pyhdf,python,ubuntu,Python,Ubuntu,当我尝试安装pyhdf时,会发生以下错误: 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

当我尝试安装pyhdf时,会发生以下错误:

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

你知道怎么了吗?谢谢。

您可能需要安装
libhdf4 dev
软件包


与其使用
sudo
在系统中安装软件包,不如花些时间阅读。

要解决这个问题,首先需要安装hdf开发软件包


sudo apt get install libhdf4 dev

即使使用libhdf4 dev软件包,您也可能会遇到缺少hdf.h文件的问题(我确实遇到过)。似乎code setup.py(在安装档案中)没有正确处理指定HDF4库所在位置的环境变量

我按照的分步说明解决了问题,但您必须在命令行中添加hdf库,而不是将其导出:

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

sudo python setup.py install -i $INCLUDE_DIRS
如果没有/want szlib,NOSZIP变量也会出现同样的问题,但我在第29行修改了setup.py:

szip_installed=False

然后安装就可以了。

有时候,在Ubuntu上安装基于C的python库(比如numpy,可能还有这个)不是很简单。我已经用PIP把它们安装在了拱门上,没有任何痛苦。谢谢。出现新错误:从numpy.distutils导入日志。我不知道为什么。谢谢,我这样做了,但仍然有错误。新错误发生了:/usr/lib/python2.7/dist packages/numpy/distutils/misc_util.py:252:RuntimeWarning:Parent模块“numpy.distutils”在处理numpy.distutils导入日志的绝对导入时找不到,我不知道为什么。如果您不想使用virtualenv,并且正在安装到全局命名空间,你可以试着安装ubuntu软件包
python-h5py
@Alexander,这是hdf5的,不是hdf4的。答案很好。很遗憾,他们还没有修复setup.py。