3

I am trying to install netcdf4-python on a MacOSX Monterey with M1 processor.

I installed without problems hdf5 and netcdf using brew.

However, after cloning the netcfd4 python repo at https://github.com/Unidata/netcdf4-python, when I then try to install netcdf4-python with python setup.py build I get the error below. I googled a bit and it seems that the brew installation of hdf5 does not include hdf5.pc so I wonder if someone found a way to circumvent this problem.

I am running python 3.9.9

Thanks for your help

Marco

Collecting netcdf4
  Using cached netCDF4-1.5.8.tar.gz (767 kB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/mpagani/.pyenv/versions/3.9.9/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/j5/vpmn9x657d3gzwvrx2vryvc80000gn/T/pip-install-y1xv724i/netcdf4_95eb462bb7b74fdfbac8a5de4965d36b/setup.py'"'"'; __file__='"'"'/private/var/folders/j5/vpmn9x657d3gzwvrx2vryvc80000gn/T/pip-install-y1xv724i/netcdf4_95eb462bb7b74fdfbac8a5de4965d36b/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/j5/vpmn9x657d3gzwvrx2vryvc80000gn/T/pip-pip-egg-info-bbawe1ww
       cwd: /private/var/folders/j5/vpmn9x657d3gzwvrx2vryvc80000gn/T/pip-install-y1xv724i/netcdf4_95eb462bb7b74fdfbac8a5de4965d36b/
  Complete output (29 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
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/j5/vpmn9x657d3gzwvrx2vryvc80000gn/T/pip-install-y1xv724i/netcdf4_95eb462bb7b74fdfbac8a5de4965d36b/setup.py", line 409, in <module>
      _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs)
    File "/private/var/folders/j5/vpmn9x657d3gzwvrx2vryvc80000gn/T/pip-install-y1xv724i/netcdf4_95eb462bb7b74fdfbac8a5de4965d36b/setup.py", line 360, in _populate_hdf5_info
      raise ValueError('did not find HDF5 headers')
  ValueError: did not find HDF5 headers
  reading from setup.cfg...
  using nc-config...
  checking /opt/homebrew/Cellar/netcdf/4.8.1/include ...
  hdf5 headers not found in /opt/homebrew/Cellar/netcdf/4.8.1/include
  nc-config did provide path to HDF5 headers, search standard locations...
      HDF5_DIR environment variable not set, checking some standard locations ..
  checking /Users/mpagani/include ...
  hdf5 headers not found in /Users/mpagani/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
  ----------------------------------------
2
  • Any luck @marco? Commented Dec 30, 2021 at 12:43
  • 1
    @CharmingRobot After some googling, I found this: github.com/Unidata/netcdf4-python/issues/562. Following the instruction provided I managed to complete the installation from sources. Commented Mar 12, 2022 at 18:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.