我環境是 python 3.9 + macOS 10.15 (catalina), 在使用 opencv 時,會出現錯誤,聽說 macOS 10.14 4.5.4 就會出錯。
https://forum.opencv.org/t/cannot-pip-install-opencv-4-5-4-on-macos-mojave/9901
我的錯誤訊息:
>>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module> bootstrap() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: _VTRegisterSupplementalVideoDecoderIfAvailable Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/.dylibs/libavcodec.59.37.100.dylib (which was built for Mac OS X 11.0) Expected in: /System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/.dylibs/libavcodec.59.37.100.dylib
I have MAC osx 10.15 catalina so that for sure can be the problem, but how do I fix it? I don’t want to upgrade to macOS 11.
解法:
python3 -m pip install opencv-python==4.5.1.48 Collecting opencv-python==4.5.1.48