Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For python, install hdf5/netcdf4

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?

like image 865
confused Avatar asked Mar 22 '16 20:03

confused


3 Answers

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.

like image 78
tuned Avatar answered Oct 22 '22 07:10

tuned


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
like image 45
Pedro Piter Avatar answered Oct 22 '22 07:10

Pedro Piter


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.

like image 2
swineone Avatar answered Oct 22 '22 06:10

swineone