【问题标题】:hdf5 dependencies trying to install netcdf4hdf5 依赖项尝试安装 netcdf4
【发布时间】:2021-06-01 08:49:51
【问题描述】:

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

[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 标头而失败。

【问题讨论】:

    标签: python-2.7 pip centos7 hdf5 netcdf4


    【解决方案1】:

    ValueError: 未找到 HDF5 标头

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

    yum install hdf5-devel
    

    【讨论】:

    • 谢谢你,博士。我已经安装了 HDF5 头文件,但现在已经到了在 NetCDF4 头文件上安装失败的地步。错误信息如上。
    • 也许yum install netcdf-devel;见centos.pkgs.org/7/epel-x86_64/…
    • 安装 netcdf-devel 确实让我们克服了 pip 安装中的障碍。谢谢!我们没有提前安装 hdf5-devel 或 netcdf-devel 软件包,因为我们之前的 CentOS 6 实例没有这样做。
    猜你喜欢
    • 2016-07-09
    • 2014-07-21
    • 2021-02-08
    • 2019-03-05
    • 1970-01-01
    • 2017-11-07
    • 2020-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多