安装Keras

时间:2015-05-01 10:40:46

标签: python ubuntu-14.04 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规范是:

  • 经销商ID: Ubuntu
  • 描述: Ubuntu 14.04.2 LTS
  • 发布: 14.04
  • 代号:可信赖

2 个答案:

答案 0 :(得分:2)

您需要安装hdf5软件包才能获得所需的标头。

答案 1 :(得分:1)

真正的错误是:

  

"在/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:致命错误:hdf5.h:没有这样的文件或目录    #include" hdf5.h" "

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

运行以下命令安装头文件:

sudo apt-get install libhdf5-dev

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

sudo pip install h5py

希望这能解决您的问题