5

I'm trying to install netCDF4 on OS X with pip install netCDF4 and I am getting the following error:

------------------------------------------------------------
/usr/local/bin/pip run on Wed Aug  7 23:02:37 2013
Downloading/unpacking netCDF4

  Running setup.py egg_info for package netCDF4



    HDF5_DIR environment variable not set, checking some standard locations ..

    checking /Users/mc ...

    checking /usr/local ...

    checking /sw ...

    checking /opt ...

    checking /opt/local ...

    checking /usr ...

    Traceback (most recent call last):

      File "<string>", line 16, in <module>

      File "/var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4/setup.py", line 114, in <module>

        raise ValueError('did not find HDF5 headers')

    ValueError: did not find HDF5 headers

    Complete output from command python setup.py egg_info:



HDF5_DIR environment variable not set, checking some standard locations ..

checking /Users/mc ...

checking /usr/local ...

checking /sw ...

checking /opt ...

checking /opt/local ...

checking /usr ...

Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4/setup.py", line 114, in <module>

    raise ValueError('did not find HDF5 headers')

ValueError: did not find HDF5 headers

----------------------------------------

Command python setup.py egg_info failed with error code 1 in /var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4

Exception information:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.py", line 107, in main
    status = self.run(options, args)
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.py", line 256, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 1042, in prepare_files
    req_to_install.run_egg_info()
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 236, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/util.py", line 612, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4

I already installed HDF5 to /usr/local/hdf5/ but I'm still getting the same error. I'm a new to Python so any help will be greatly appreciated.

Thank you.

Julien Chastang
  • 17,592
  • 12
  • 63
  • 89
mchangun
  • 9,814
  • 18
  • 71
  • 101
  • I have been using [these instruction](https://github.com/SciTools/installation-recipes/blob/master/osx10.8/install.txt) to install netcdf4-python on OS X. You probably only need to go as far as step 6. And virtual environments are quite nice. – Julien Chastang Aug 07 '13 at 16:00

3 Answers3

3

You might need to set the HDF5_DIR environment variable to the location where you install HDF5; it's looking in the standard install paths and not finding the headers for HDF5 - hence at least one of your errors.

You can simply set it before calling pip:

HDF5_DIR=/usr/local/hdf5 pip install netCDF4

or export it and then call pip:

export HDF5_DIR=/usr/local/hdf5
pip install netCDF4
chander
  • 1,997
  • 2
  • 16
  • 15
  • One of the standard install paths is `/usr/local` - but that's where my HDF5 is installed. – mchangun Aug 07 '13 at 15:31
  • Perhaps you need to set the HDF5_DIR to "/usr/local/hdf5/" - where hdf5 is installed (as you noted in your question.) – chander Aug 07 '13 at 15:33
  • 1
    @mchangun See this link: http://stackoverflow.com/questions/4972079/unable-to-reinstall-pytables-for-python-2-7 – Riet Feb 12 '15 at 01:28
1

If you don't need the latest version --prefer-binary flag to pip may solve it:

pip install netcdf4 --prefer-binary
Martin Alexandersson
  • 1,269
  • 10
  • 12
0

Simply try this procedure to install netCDF4

  1. install HDF5 from link

  2. install netcdf4 from link

  3. install netcdf4-python from link

For detail visit link

3ppps
  • 933
  • 1
  • 11
  • 24