For python, install hdf5/netcdf4
Solution 1
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.
Solution 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
Solution 3
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.
confused
Updated on June 19, 2022Comments
-
confused almost 2 years
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 containing
hdf5.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 about 8 yearsI've just did that but I'm still getting the same No module named hdf5 and/or netcdf4.
-
tuned about 8 yearsHave you done these steps: * install Linux libraries * pip install h5py * pip install netcdf4-python? Have you installed python-dev?
-
confused about 8 yearsThe 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.
-
tuned about 8 years@confused have you tried to update
pip
to the latest version? Have younumpy
installed? For me installing these two dependenciesnumpy==1.10.2
netCDF4==1.2.2
on Python 3.5 works fine. Have you tried this stackoverflow.com/questions/28931204/… ? -
confused about 8 yearsI 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 about 8 yearsWould 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.