【问题标题】:Linux error when installing Keras安装 Keras 时出现 Linux 错误
【发布时间】:2015-07-11 04:50:18
【问题描述】:

在 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
  • 代号:值得信赖的

【问题讨论】:

  • 问题似乎很明显,它需要一个名为 hdf5.h 的文件在您的包含路径上,而您没有。大概您忘记安装其中一个先决条件(或者 repo 的作者忘记记录它),很可能是名称中带有“hdf5”的库。 (另请注意,在许多 linux 发行版中,库被分成两个包,例如 hdf5hdf5-dev,因此如果您从供应商存储库安装,您将需要后者,而不仅仅是前者,以获取开发文件。 )
  • 太棒了,我缺少的是 libhdf5-dev。我已经安装了 Keras,谢谢你们。
  • 供将来参考:使用“code”按钮,而不是“code sn-p”按钮,包括 Python 代码、shell 脚本代码和输出等内容; code sn-ps 仅适用于您希望在页面上运行的 JavaScript 代码。
  • 会做,明白,再次感谢。

标签: python ubuntu-14.04 keras


【解决方案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

希望这能解决您的问题

【讨论】:

    【解决方案2】:

    你需要安装hdf5 包来获取你需要的头文件。

    【讨论】:

    • 谢谢,对我来说不是那么明显。我不习惯阅读 Linux 错误,但从中吸取了教训。再次感谢。工作!!
    猜你喜欢
    • 1970-01-01
    • 2018-04-29
    • 2011-05-18
    • 2018-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多