Linux安装Keras时出错

Linux error when installing Keras

我在 Ubuntu 服务器上安装 Keras 时遇到这个奇怪的错误:

Cythonizing /tmp/easy_install-qQggXs/h5py-2.5.0/h5py/utils.pyx
In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1804:0,
                 from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from /tmp/easy_install-qQggXs/h5py-2.5.0/h5py/api_compat.h:26,
                 from /tmp/easy_install-qQggXs/h5py-2.5.0/h5py/defs.c:287:
/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^
In file included from /tmp/easy_install-qQggXs/h5py-2.5.0/h5py/defs.c:287:0:
/tmp/easy_install-qQggXs/h5py-2.5.0/h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory
 #include "hdf5.h"
                  ^
compilation terminated.
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

有解决此问题的想法吗?

我已经从 https://github.com/fchollet/keras 下载了 Keras 存储库,并使用此命令进行安装:

sudo python setup.py install

我的 Linux 规格是:

您需要安装 hdf5 软件包以获得您需要的 headers。

真正的错误是:

"In file included from /tmp/easy_install-qQggXs/h5py-2.5.0/h5py/defs.c:287:0: /tmp/easy_install-qQggXs/h5py-2.5.0/h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory #include "hdf5.h" "

此错误表示缺少头文件 hdf5.h。

运行安装头文件的命令如下:

sudo apt-get install libhdf5-dev

请注意,要安装 h5py 包,运行 以下命令:

sudo pip install h5py

希望这能解决您的问题