[Mac Pro M1] Python3.9 import cv2 Error: Reason: image not found

If you forget to copy the original error message, the content is similar to:

>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
"/Users/xxx/Anaconda/anaconda/envs/python35/lib/python3.5/site-packages/cv2/__init__.py", line 4, in <module>
    from .cv2 import *
ImportError: dlopen(/Users/xxx/Anaconda/anaconda/envs/python35/lib/python3.5/site-packages/cv2/cv2.cpython-35m-darwin.so, 2): Library not loaded: /System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage
  Referenced from: /Users/xxx/Anaconda/anaconda/envs/python35/lib/python3.5/site-packages/cv2/.dylibs/libavcodec.57.107.100.dylib
  Reason: image not found
>>> `

The breakthrough is also in the error report, which indicates that the libavcodec library may be missing or have problems. The solution is to install the library


$ brew install libav
$ brew install ffmpeg

Read More: