12

Doing this on a Linux Mint 17.1.

When I try:

pip install hdf5

I get the error

"Could not find a version that satisfies the requirement hdf5 (from versions: ) No matching distribution found for hdf5"

I'm trying in the long run to install netcdf4 but can't do that until I get hdf5 installed. Supposedly from when I was trying to do this last week, with netcdf4, I should be using the pip install netcdf4, err hdf5...at least maybe in the case of hdf5.

If I try pip install h5py I get that the message saying:

Requirement already satisfied (use --upgrade to upgrade): h5py in ./anaconda3/lib/python3.5/site-packages Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in ./anaconda3/lib/python3.5/site-packages (from h5py) Requirement already satisfied (use --upgrade to upgrade): six in ./anaconda3/lib/python3.5/site-packages (from h5py)

Yet if I go ahead and try pip install netcdf4 it comes up and says:

Collecting netcdf4 Using cached netCDF4-1.2.3.1.tar.gz Complete output from command python setup.py egg_info: Package hdf5 was not found in the pkg-config search path. Perhaps you should add the directory containinghdf5.pc' to the PKG_CONFIG_PATH environment variable No package 'hdf5' found cython version 0.23.4 found ... reading from setup.cfg...

HDF5_DIR environment variable not set, checking some standard locations ..
checking /home/meant2b ...
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-build-pq3yt4ek/netcdf4/setup.py", line 286, 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 /tmp/pip-build-pq3yt4ek/netcdf4/`

When I search the files I don't find a hdf5.pc file.

Is there a difference between h5py and hdf5? Do I have to compile and install hdf5 from the individual files or can I pip install.

What do I have to do to be able to install both hdf5 and netcdf4?

confused
  • 1,283
  • 6
  • 21
  • 37
  • I recently did the same thing in Kubuntu and ran into a similar problem. For me it helped to install hdf5-helpers and hdf5-tools (not via pip, but apt-get) and requirements thereof. This is not a real answer to your question, just possibly a quick workaround. – StefanS Mar 22 '16 at 20:30
  • If I remember correctly back to last week when I had the time and was trying to do this I had seen the same mention somewhere and tried it with the same 'lack' of results that I'm still getting. – confused Mar 22 '16 at 20:33
  • Did you try installing these packages within Anaconda? `conda install hdf5`and `conda install netcdf4` – N1B4 Mar 22 '16 at 20:53
  • Just tried conda but when I go into Idle and type in from netcdf4 import Dataset I get No module named netcdf4. Will I have to use Anaconda or can I still 'grab' onto hdf5 and netcdf4? If I go and search the hard drive it still doesn't find hdf5.pc. I also get No module named hdf5 if I try to import it through Idle as well. – confused Mar 22 '16 at 21:02
  • The import command for netcdf is case-sensitive: `>>> import netCDF4`. Try that import command, making sure you capitalize CDF4. – N1B4 Mar 23 '16 at 19:14

3 Answers3

9

You need to install the HDF5 libraries for your Linux distribution. In Ubuntu is:

sudo apt-get install libhdf5-serial-dev netcdf-bin libnetcdf-dev

See this link.

tuned
  • 1,085
  • 10
  • 14
  • I've just did that but I'm still getting the same No module named hdf5 and/or netcdf4. – confused Mar 22 '16 at 21:36
  • Have you done these steps: * install Linux libraries * pip install h5py * pip install netcdf4-python? Have you installed python-dev? – tuned Mar 22 '16 at 21:44
  • 1
    The first two work okay but when I got to * pip install netcdf4-python * I get the error Could not find a version that satisfies the requirement. No matching distribution found for netcdf4-python. If I just * pip install netcdf4 it says the Requirement already satisfied. So I decided to try to upgrade netcdf4 which it says it successfully install netcdf4-1.2.3.1 but I still get the same No module named netcdf4 when I type in import netcdf4 in Idle. – confused Mar 22 '16 at 21:54
  • @confused have you tried to update `pip` to the latest version? Have you `numpy` installed? For me installing these two dependencies `numpy==1.10.2` `netCDF4==1.2.2` on Python 3.5 works fine. Have you tried this http://stackoverflow.com/questions/28931204/hdf5-headers-missing-in-installation-of-netcdf4-module-for-python ? – tuned Mar 23 '16 at 08:48
  • I just checked and the netCDF4 still gives me the error. I'm on Linux Mint 17.1 not Windows. Is the only way to install hdf5 by doing a Cpython build or can you pip/apt-get it and get it work correctly. Everything I see references back to finding hdf5.pc file which I can't find on the hard drive. I do find a couple of hdf5.py files when I do the search but a 'y' and 'c' seems quite far away from each other to be a mistake in typing in some posts I have seen. Most of those posts seems like they are going back to doing a Cpython build of hdf5. – confused Mar 24 '16 at 01:15
  • Would I have to compile numpy to update it. I'm on 1.8.2 and I don't seem to find a version newer directly downloadable/installable without compiling it. Even Anaconda seems to have 1.8.2. I do have netCDF4 1.2.3.1 and depending, Idle is ver 3.4. Anaconda is Spyder dependent which I have only stumbled into Python 2.7 thus far when I download Spyder. I rarely have to fess but now I'm totally lost and confused on this. Python really needs to make itself much easier to use as a whole. – confused Mar 24 '16 at 01:35
2

I had the same issue in Debian 8. To fix it, as root, I installed the libraries, then linked the serial headers to a include dir inside the hdf5 libraries, exported the HDF_DIR path and installed netCDF4:

# apt-get install -y libhdf5-dev libnetcdf-dev
# ln -s /usr/include/hdf5/serial /usr/include/hdf5/include
# export HDF5_DIR=/usr/include/hdf5
# pip install netCDF4
2

I had the same error under macOS Catalina. Had to install the hdf5 and netcdf4 packages from Homebrew:

brew install hdf5 netcdf4

Afterwards, pip3 install netcdf4 worked fine.

swineone
  • 2,296
  • 1
  • 18
  • 32