Python: Error importing OpenCV
Question: I installed opencv with Homebrew. I'm getting the following error -

    
    
    >>> import cv2
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: /usr/local/lib/libpng16.16.dylib
      Referenced from: /usr/local/Cellar/opencv/2.4.11_1/lib/libopencv_highgui.2.4.dylib
      Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 34.0.0 or later, but libpng16.16.dylib provides version 33.0.0
    

How do I fix this?


Answer: 
    Library not loaded: /usr/local/lib/libpng16.16.dylib
    

^ libpng hasn't been loaded for some reason

    
    
    Referenced from: /usr/local/Cellar/opencv/2.4.11_1/lib/libopencv_highgui.2.4.dylib
    

^ highgui tried to load it.

    
    
    Reason: Incompatible library version
    

^ `libopencv_highgui` looks to require at least version 34.0.0 of `libpng`,
whereas you have version 33.0.0. I expect updating libpng should do the trick.

