Question

I am using Anaconda on OS X Mavericks. When I try loading cv2 I get an import error (see below). Do you know how to fix this?

>>import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/usr/local/Cellar/opencv/2.4.8.2/lib/python2.7/site-packages/cv2.so,    
2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/Cellar/opencv/2.4.8.2/lib/libopencv_highgui.2.4.dylib
Reason: image not found

I am not sure it's relevant, but in /usr/local/lib/ I have libpng16.16.dylib instead of libpng15.15.dylib.

Was it helpful?

Solution 2

As suggested in this issue, I fixed this problem by simply executing

conda update hdf5

OTHER TIPS

This is the solution I found:

you could also just add it to your PYTHONPATH. here's how: you should be able to get it to load through one of the other (non anaconda) python executables. mine were located at: /usr/bin/python (default system python) and /usr/local/bin/python (brew)

  • call the python executable using the full path
  • once you successfully import cv2 run: cv2.__file__ this will give you the file's path which you can then take (full directory path not including filename) and add as the first argument to your PYTHONPATH defined in ~/.bash_profile
  • after changing the .bash_profile don't forget to run source ~/.bash_profile to make the changes effective
  • fire up anaconda python and it should now find cv2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top