For python, install hdf5/netcdf4

守給你的承諾、 提交于 2019-12-07 02:17:24

问题


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?


回答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.




回答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


来源:https://stackoverflow.com/questions/36164410/for-python-install-hdf5-netcdf4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!