TensorFlow-Object-Detection-on-the-Raspberry-Pi: ImportError: libImath-2_2.so.12: cannot open shared object file: No such file or directory

Heya I’m trying to run the command "python3 Object_detection_picamera.py " and I keep getting the this stack being returned:

Traceback (most recent call last):
  File "Object_detection_picamera.py", line 23, in <module>
    import cv2
  File "/home/pi/.local/lib/python3.5/site-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libImath-2_2.so.12: cannot open shared object file: No such file or directory

I have followed all the instructions and just wondering what is the problem - have I missed something or is there something else that I need to install?

Thank you

Osian

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Install the following packages with apt-get:

libilmbase-dev libopenexr-dev libgstreamer1.0-dev

Worked for me!

Hello, I encountered the same error. Install was on a brand new Raspberry Pi 4b with the Raspbian Lite OS.

ImportError: libImath-2_2.so.12: cannot open shared object file: No such file or directory.

I traced the dependencies and found that “libImath” is part of the libilmbase23 package, so this fixed the problem:

sudo apt install libilmbase23

However, that led to a second problem:

ImportError: libIlmImf-2_2.so.22: cannot open shared object file: No such file or directory

Again, tracing the dependencies led to “libIlmImf” being part of the libopenexr package. This was only available in a dev package, so the fixed the second problem:

sudo apt install libopenexr-dev

And boom! We are up and running. Hope this helps.

This is still an open issue. The above apt-gets didnt solve the problem in Raspberry Pi 4.

this is no libilmbase23, how to fix it

For me after installing sudo apt install libopenexr-dev, I installed another library which is missing sudo apt-get install -y libgtk-3-dev

Hello, I encountered the same error. Install was on a brand new Raspberry Pi 4b with the Raspbian Lite OS.

ImportError: libImath-2_2.so.12: cannot open shared object file: No such file or directory.

I traced the dependencies and found that “libImath” is part of the libilmbase23 package, so this fixed the problem:

sudo apt install libilmbase23

However, that led to a second problem:

ImportError: libIlmImf-2_2.so.22: cannot open shared object file: No such file or directory

Again, tracing the dependencies led to “libIlmImf” being part of the libopenexr package. This was only available in a dev package, so the fixed the second problem:

sudo apt install libopenexr-dev

And boom! We are up and running. Hope this helps.

This solved the issue for me!

I have Raspbian Lite with no UI installed on a Pi 3A+. I followed @rribani’s instructions above which got me past the error in this issue, but I encountered a further problem when the script couldn’t find the picamera Python module. I installed that using sudo apt-get install python3-picamera.

That allowed the script to work, but it killed itself after a minute or so with a std::bad_alloc exception, likely because it couldn’t create a window to show the image from the camera.

Now I’m loading a minimal PIXEL desktop… stay tuned.