Search code examples
pythonmacosopencventhoughtcanopy

Enthought Canopy Python and OpenCV


I've installed Enthought Canopy Python 2.7.3 64-bit and it has OpenCV 2.4.2. When I import cv2 I get the following error:

>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/Foo/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: @executable_path/../Python
  Referenced from: /Users/Foo/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cv2.so
  Reason: image not found

This post suggests that the solution is to run install_name_tool -change... but I do not know what options to pass it, and am not familiar enough with dynamic libraries to understand the man page, so I turn here for help.


Solution

  • install_name_tool -change @executable_path/../Python $HOME/Library/Enthought/Canopy_64bit/User/Python $HOME/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cv2.so
    

    Thanks to original author who also replied completing thread at link in the question.