无法在Windows上通过pip安装netCDF4

时间:2019-09-05 09:08:30

标签: python windows

我刚刚在Windows 10上安装了“ vanilla” python,并尝试安装netCDF4,结果发现它给出了一条错误消息: “ ValueError:找不到HDF5标头”

这是Python 3.7,版本如下:

py -m pip list
Package            Version
------------------ -------
attrs              19.1.0
backcall           0.1.0
bleach             3.1.0
bokeh              1.3.4
colorama           0.4.1
cycler             0.10.0
Cython             0.29.13
decorator          4.4.0
defusedxml         0.6.0
entrypoints        0.3
h5py               2.9.0
ipykernel          5.1.2
ipython            7.8.0
ipython-genutils   0.2.0
ipywidgets         7.5.1
jedi               0.15.1
Jinja2             2.10.1
jsonschema         3.0.2
jupyter            1.0.0
jupyter-client     5.3.1
jupyter-console    6.0.0
jupyter-core       4.5.0
kiwisolver         1.1.0
MarkupSafe         1.1.1
matplotlib         3.1.1
mistune            0.8.4
nbconvert          5.6.0
nbformat           4.4.0
notebook           6.0.1
numpy              1.17.1
packaging          19.1
pandas             0.25.1
pandocfilters      1.4.2
parso              0.5.1
pickleshare        0.7.5
Pillow             6.1.0
pip                19.2.3
pip-review         1.0
pivottablejs       0.9.0
prometheus-client  0.7.1
prompt-toolkit     2.0.9
Pygments           2.4.2
pyparsing          2.4.2
pypl               40.10
pyrsistent         0.15.4
python-dateutil    2.8.0
pytz               2019.2
pywinpty           0.5.5
PyYAML             5.1.2
pyzmq              18.1.0
qtconsole          4.5.5
scipy              1.3.1
seaborn            0.9.0
Send2Trash         1.5.0
setuptools         41.2.0
six                1.12.0
svgwrite           1.3.1
terminado          0.8.2
testpath           0.4.2
tornado            6.0.3
traitlets          4.3.2
virtualenv         16.7.5
wcwidth            0.1.7
webencodings       0.5.1
widgetsnbextension 3.5.1
xarray             0.12.3

当我尝试使用pip安装netCDF时,出现错误。 整个错误消息是:

>py -m pip install netCDF4
Collecting netCDF4
  Using cached 

 https://files.pythonhosted.org/packages/64/2e/abc0bce095ab5a3b8374f052ace2509a031fd7633b23917e557487067225/netCDF4-1.5.2.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'c:\python37-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\***\\AppData\\Local\\Temp\\pip-install-374v_ecc\\netCDF4\\setup.py'"'"'; __file__='"'"'C:\\Users\\***\\AppData\\Local\\Temp\\pip-install-374v_ecc\\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: C:\Users\***\AppData\Local\Temp\pip-install-374v_ecc\netCDF4\
    Complete output (16 lines):
    reading from setup.cfg...

        HDF5_DIR environment variable not set, checking some standard locations ..
    checking C:\Users\***...
    checking /usr/local ...
    checking /sw ...
    checking /opt ...
    checking /opt/local ...
    checking /usr ...
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\***\AppData\Local\Temp\pip-install-374v_ecc\netCDF4\setup.py", line 397, in <module>
        _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs)
      File "C:\Users\***\AppData\Local\Temp\pip-install-374v_ecc\netCDF4\setup.py", line 345, 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.

请告诉我该怎么做或您需要什么信息。 谢谢。

1 个答案:

答案 0 :(得分:0)

我自己解决了这个问题。 我需要手动安装C ++编译器,因为它没有包含在香草python软件包中(当然)。

我从以下站点下载并安装了“ Visual Studio构建工具”: https://visualstudio.microsoft.com/downloads/ 这样就解决了问题。