0

I get this error whenever I used to check if the opencv package is installed on python3 properly. I get this error regarding .so file which I had pasted during installation.

python3
Python 3.7.3 (default, Mar 27 2019, 09:23:39) 
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/cv2/__init__.py", line 89, in <module>
    bootstrap()
  File "/usr/local/lib/python3.7/site-packages/cv2/__init__.py", line 79, in bootstrap
    import cv2
ImportError: dlopen(/usr/local/lib/python3.7/site-packages/cv2/python-3.7/cv2.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/ilmbase/lib/libImath-2_2.23.dylib
  Referenced from: /usr/local/Cellar/opencv/4.0.1/lib/libopencv_imgcodecs.4.0.dylib
  Reason: image not found
>>>
Community
  • 1
  • 1
Jasch
  • 19
  • 1
  • 6

1 Answers1

7

I am guessing that you installed Python3 and OpenCV using Homebrew based on "Cellar" being on the path in the error message:

ImportError: dlopen(/usr/local/lib/python3.7/site-packages/cv2/python-3.7/cv2.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/ilmbase/lib/libImath-2_2.23.dylib
  Referenced from: /usr/local/Cellar/opencv/4.0.1/lib/libopencv_imgcodecs.4.0.dylib

I think you are using this version of python3:

/usr/local/lib/python3.7/site-packages

but one of the following happened:

  1. You installed opencv-python somewhere else (ex. using a different python or pip binary)
  2. You incorrectly installed or manually modified your OpenCV installation (you mentioned "regarding .so file which I had pasted during installation", maybe some symlinks were not properly updated)

Try re-installing with that specific version of python3:

$ which python3
/usr/local/bin/python3

$ /usr/local/bin/python3 -m pip install --force-reinstall opencv-python 
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135