尝试安装 netcdf4 的 hdf5 依赖项

时间:2021-03-02 19:12:50

标签: python-2.7 pip centos7 hdf5 netcdf4

我正在尝试在运行 Python 2.7 的 CentOS 7 系统上通过 pip 安装 NetCDF4。已经通过 yum 安装了以下 HDF5 包:

[user@host]$ rpm -qa | grep hdf5
hdf5-openmpi-1.8.12-12.el7.x86_64
hdf5-1.8.12-11.el7.x86_64

尽管安装了软件包,但我在尝试安装 hdf5 时仍然遇到此错误:

[user@host]$ pip install -r requirements.txt 
.
.
.
Collecting netCDF4>=1.1.1 (from -r requirements.txt (line 9))
  Using cached https://files.pythonhosted.org/packages/79/0d/caa957cc1b42b718ce4b9b3e849e6f7aa99faad2d522d8f2d7a33500fba0/netCDF4-1.5.6.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /home/ooiui/miniconda2/envs/ooiui279/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cOs19I/netCDF4/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cOs19I/netCDF4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-cOs19I/netCDF4/
    Complete output (30 lines):
    Package hdf5 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `hdf5.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'hdf5' found
    reading from setup.cfg...
    
        HDF5_DIR environment variable not set, checking some standard locations ..
    checking /home/ooiui/miniconda2/envs/ooiui279/include ...
    hdf5 headers not found in /home/ooiui/miniconda2/envs/ooiui279/include
    checking /home/ooiui/miniconda2/envs/ooiui279/Library/include ...
    hdf5 headers not found in /home/ooiui/miniconda2/envs/ooiui279/Library/include
    checking /home/ooiui/include ...
    hdf5 headers not found in /home/ooiui/include
    checking /usr/local/include ...
    hdf5 headers not found in /usr/local/include
    checking /sw/include ...
    hdf5 headers not found in /sw/include
    checking /opt/include ...
    hdf5 headers not found in /opt/include
    checking /opt/local/include ...
    hdf5 headers not found in /opt/local/include
    checking /usr/include ...
    hdf5 headers not found in /usr/include
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-cOs19I/netCDF4/setup.py", line 425, in <module>
        _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs)
      File "/tmp/pip-install-cOs19I/netCDF4/setup.py", line 366, in _populate_hdf5_info
        raise ValueError('did not find HDF5 headers')
    ValueError: did not find HDF5 headers
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

过去,当我在 CentOS 6 上安装 NetCDF4 时,我不需要做任何特殊的调整。有什么需要额外准备的变化吗?提前致谢。

感谢 phd,我安装了 HDF5 标头并将 HDF5_DIR 环境变量设置为 /include 以反映安装位置。现在我似乎遇到了 NetCDF4 本身的类似障碍:

Collecting netCDF4>=1.1.1 (from -r requirements.txt (line 9))
  Using cached https://files.pythonhosted.org/packages/79/0d/caa957cc1b42b718ce4b9b3e849e6f7aa99faad2d522d8f2d7a33500fba0/netCDF4-1.5.6.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /home/ooiui/miniconda2/envs/ooiui279/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l853Xs/netCDF4/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l853Xs/netCDF4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-l853Xs/netCDF4/
    Complete output (23 lines):
    Package hdf5 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `hdf5.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'hdf5' found
    reading from setup.cfg...
    checking /usr/include ...
    HDF5 library version: 1.8.12 headers found in /usr/include
    HDF5 library version: 1.8.12 found in /usr
    
    NETCDF4_DIR environment variable not set, checking standard locations..
    checking /home/ooiui/miniconda2/envs/ooiui279 ...
    checking /home/ooiui/miniconda2/envs/ooiui279/Library ...
    checking /home/ooiui ...
    checking /usr/local ...
    checking /sw ...
    checking /opt ...
    checking /opt/local ...
    checking /usr ...
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-l853Xs/netCDF4/setup.py", line 441, in <module>
        raise ValueError('did not find netCDF version 4 headers')
    ValueError: did not find netCDF version 4 headers
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我们正在尝试根据 requirements.txt 文件通过 pip 安装 NetCDF4,但它似乎因缺少 NetCDF4 标头而失败。

1 个答案:

答案 0 :(得分:0)

<块引用>

ValueError: 没有找到 HDF5 标头

错误表示没有开发文件。你有图书馆,但没有标题。安装:

yum install hdf5-devel
相关问题