Python 在 Ubuntu 服务器上安装 h5py

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24744969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 05:06:27  来源:igfitidea点击:

Installing h5py on an Ubuntu server

pythonpython-2.7installationinstallerh5py

提问by Devil

I was installing h5py on an Ubuntu server. However it seems to return an error that h5py.his not found. It gives the same error message when I install it using pipor the setup.pyfile. What am I missing here?

我正在 Ubuntu 服务器上安装 h5py。然而,它似乎返回一个h5py.h未找到的错误。当我使用pipsetup.py文件安装它时,它会给出相同的错误消息。我在这里缺少什么?

I have Numpy version 1.8.1, which higher than the required version of 1.6 or above.

我有 Numpy 1.8.1 版本,高于所需的 1.6 或更高版本。

The complete output is as follows:

完整的输出如下:

van@Hulk:~/h5py-2.3.1? sudo python setup.py install
libhdf5.so: cannot open shared object file: No such file or directory
HDF5 autodetection failed; building for 1.8.4+
running install
running bdist_egg
running egg_info
writing h5py.egg-info/PKG-INFO
writing top-level names to h5py.egg-info/top_level.txt
writing dependency_links to h5py.egg-info/dependency_links.txt
reading manifest file 'h5py.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.c' under directory 'win_include'
warning: no files found matching '*.h' under directory 'win_include'
writing manifest file 'h5py.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/h5py
copying h5py/ipy_completer.py -> build/lib.linux-x86_64-2.7/h5py
copying h5py/__init__.py -> build/lib.linux-x86_64-2.7/h5py
copying h5py/version.py -> build/lib.linux-x86_64-2.7/h5py
copying h5py/highlevel.py -> build/lib.linux-x86_64-2.7/h5py
creating build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/group.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/files.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/selections.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/__init__.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/filters.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/base.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/dims.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/datatype.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/dataset.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/selections2.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/attrs.py -> build/lib.linux-x86_64-2.7/h5py/_hl
creating build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_selections.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_group.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_h5.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_attrs.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_objects.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_slicing.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_h5t.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_datatype.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/__init__.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_dimension_scales.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_base.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_dataset.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_file.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_h5p.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_attrs_data.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/common.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_h5f.py -> build/lib.linux-x86_64-2.7/h5py/tests
running build_ext
skipping 'h5py/defs.c' Cython extension (up-to-date)
building 'h5py.defs' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/h5py
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DH5_USE_16_API -I/home/govinda/h5py-2.3.1/lzf -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c h5py/defs.c -o build/temp.linux-x86_64-2.7/h5py/defs.o
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1761:0,
                 from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from h5py/api_compat.h:26,
                 from h5py/defs.c:342:
/usr/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 h5py/defs.c:342:0:
h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory
 #include "hdf5.h"
                  ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

采纳答案by MattDMo

You need to install libhdf5-devto get the required header files. Just run

您需要安装libhdf5-dev以获取所需的头文件。赶紧跑

sudo apt-get install libhdf5-dev

and it should install it and its dependencies automatically.

它应该自动安装它及其依赖项。

Don't worry about the NumPy warning, it just means that the package developers are using an old version of the API, but everything will still work.

不要担心 NumPy 警告,它只是意味着包开发人员正在使用旧版本的 API,但一切仍然有效。

回答by KyungHoon Kim

You can use python-h5py.

您可以使用python-h5py

sudo apt-get install python-h5py

须藤 apt-get 安装 python-h5py

And then in your Python file try:

然后在你的 Python 文件中尝试:

import h5py

导入 h5py

回答by Gx1sptDTDa

It is generally preferable to use pipinstead of installing it manually, since pip will also install all python dependencies. You would still need your header files though.

通常最好使用pip而不是手动安装它,因为 pip 还将安装所有 python 依赖项。你仍然需要你的头文件。

so:

所以:

sudo apt-get install libhdf5-dev
pip install h5py

回答by vierja

In my case (Ubuntu 15.04) installing libhdf5-devwas not enough.

在我的情况下(Ubuntu 15.04)安装libhdf5-dev是不够的。

I had to run:

我不得不跑:

HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial/ pip install h5py

HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial/ pip install h5py

to make it work.

使其工作。

回答by Niklas

I had to install both libhdf5-devand cython3(Ubuntu 18.04 on arm64 device, Python 3.5).

我必须同时安装libhdf5-devcython3(arm64 设备上的 Ubuntu 18.04,Python 3.5)。

sudo apt install libhdf5-dev
sudo apt install cython3