When installing opencv-python on Mac using pip, the following error happens.
/Users/zhaojun/Github/OpenCV_Demo/venv/bin/python /Users/zhaojun/Github/OpenCV_Demo/venv/com.ctrip.com/nowatermarkdemo.py Traceback (most recent call last): File "/Users/zhao'un/Github/OoenCV Demo/venv/com ctrio com/nowatermarkdemo ov", line 1, in <module> import cv2 as cv File
"/Dsers/zhao"un/Github/DoenCV Demo/venv/lib/ovthon3 9/site-oacka es/cv2/ init.cv", line 5, in <module> from .cv2 import * ImportError: dlopen(/Users/zhaojun/Github/OpenCV_Demo/venv/lib/python3.9/site-packages/cv2/cv2.cpython-39-darwin.so, 2): Library not loaded:
|/opt/homebrew/opt/ffmpeg/lib/libavcodec.58.dylib Referenced from: /Users/zhaojun/Github/OpenCV_Demo/venv/lib/python3.9/site-packages/cv2/cv2.cpython-39-darwin.so Reason: image not found'
Process finished with exit code 1
And opencv does not get installed.
Things that I have read of, but are not viable options:
- Using Rosetta option with terminal: This works, but it causes other issues with other libraries.
- Using Conda and building from source: Cannot use Conda, need to use pip
- Building from source: Too complex, gives similar errors along the way.