Search code examples
linuxopencvraspberry-pi3raspbian

Raspberry Pi and OpenCV can't install libhdf5-100


I am trying to downgrade and install an older version of a package which I need for OpenCv to install.

So when I try to install it I get this error:

pi@raspberrypi:~ $ sudo apt-get install libhdf5-100
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libhdf5-100 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libhdf5-103

E: Package 'libhdf5-100' has no installation candidate

I need the libhdf5-100 over the 103 for opencv to install and run correctly. I installed Opencv correctly but get this error when trying to import it.

(mypi) pi@raspberrypi:~ $ python
Python 3.5.4 (default, Sep  5 2017, 18:32:10) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/mypi/lib/python3.5/site-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libhdf5_serial.so.100: cannot open shared object file: No such file or directory
>>> exit()

How can I fix this and install the 100 version?


Solution

  • Ok I found the workaround for it. So you need Buster to upgrade to the OS for this to work and then its pretty simple to do from here.

    First, install all the dependencies you will need.

    sudo apt-get update && sudo apt-get upgrade
    sudo apt-get install build-essential cmake pkg-config
    sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng-dev
    sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
    sudo apt-get install libxvidcore-dev libx264-dev
    sudo apt-get install libfontconfig1-dev libcairo2-dev
    sudo apt-get install libgdk-pixbuf2.0-dev libpango1.0-dev
    sudo apt-get install libgtk2.0-dev libgtk-3-dev
    sudo apt-get install libatlas-base-dev gfortran
    sudo apt-get install libhdf5-dev libhdf5-serial-dev libhdf5-103
    sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
    sudo apt-get install python3-dev
    

    You then will create a virtual environment using python 3.7. After that, it is a simple pip command to get it to work

    pip install opencv-contrib-python==4.1.0.25
    

    I hope this helps out someone who gets stuck. The old method will not work anymore so I wasted a a good day doing it.