jrobchin / Computer-Vision-Basics-with-Python-Keras-and-OpenCV

Full tutorial of computer vision and machine learning basics with OpenCV and Keras in Python.
429 stars 125 forks source link

Can not import cv2 #1

Closed hardcookies closed 6 years ago

hardcookies commented 6 years ago

Hi, I installed the packages as README.md. But when I import cv2, there is a error.

import cv2

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-8-c8ec22b3e787> in <module>()
----> 1 import cv2

ImportError: dlopen(/Users/james/anaconda3/envs/cv/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so, 2): Library not loaded: @rpath/libfreetype.6.dylib
  Referenced from: /Users/james/anaconda3/envs/cv/lib/libopencv_freetype.3.4.dylib
  Reason: Incompatible library version: libopencv_freetype.3.4.dylib requires version 22.0.0 or later, but libfreetype.6.dylib provides version 21.0.0

What should I do?

jrobchin commented 6 years ago

I would check these issues to start: https://github.com/conda-forge/opencv-feedstock/issues/69 and https://github.com/ContinuumIO/anaconda-issues/issues/1266.

I have never seen this specific error but from reading those issues, some possible troubleshooting steps could be:

  1. conda install openblas=0.2.19 See here.
  2. Create a new env and install only OpenCV: conda install -c conda-forge opencv --override-channels See here
  3. Uninstall OpenCV and install the Menpo version (Seems to work for a lot of people, just not 100% sure if all features are identical): conda uninstall opencv conda install -c https://conda.binstar.org/menpo opencv See here.

It'd also help if you posted your conda list and conda info.

hardcookies commented 6 years ago

Thank you! I have solved this problem by

conda install -c https://conda.anaconda.org/menpo opencv3
jrobchin commented 6 years ago

Great! I'll add that to the readme.