Mac系统Python3.11升级opencv-python版本之后,报错如下:
Traceback (most recent call last):
File "/Users/mac10.12/coding/stream-formatter/./stream_formatter/main.py", line 19, in <module>
from routers import streams
File "/Users/mac10.12/coding/stream-formatter/stream_formatter/routers/streams.py", line 8, in <module>
from tasks import close_it_later, do_convert
File "/Users/mac10.12/coding/stream-formatter/stream_formatter/tasks.py", line 10, in <module>
import cv2
File "/Users/mac10.12/Library/Caches/pypoetry/virtualenvs/stream-formatter-kj-F0gEP-py3.11/lib/python3.11/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/Users/mac10.12/Library/Caches/pypoetry/virtualenvs/stream-formatter-kj-F0gEP-py3.11/lib/python3.11/site-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: dlopen(/Users/mac10.12/Library/Caches/pypoetry/virtualenvs/stream-formatter-kj-F0gEP-py3.11/lib/python3.11/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: __ZNSt3__113basic_filebufIcNS_11char_traitsIcEEE4openEPKcj
Referenced from: /Users/mac10.12/Library/Caches/pypoetry/virtualenvs/stream-formatter-kj-F0gEP-py3.11/lib/python3.11/site-packages/cv2/.dylibs/libvmaf.1.dylib (which was built for Mac OS X 12.0)
Expected in: /usr/lib/libc++.1.dylib
原因是新版的cv2需要12.0以后的mac版本,而我的是11.7
解决:降低opencv-Python的版本
pip install "opencv-python<4.9"