opencv / opencv-python

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.
https://pypi.org/project/opencv-python/
MIT License
4.55k stars 853 forks source link

OpenCV 4.7 Symbol not found: on Mac 11, requires MacOS 12 #777

Closed anttiryt closed 1 year ago

anttiryt commented 1 year ago

System Information

OpenCV python version 4.7.0.68 Operation System / Platform: Macos BigSur 11.6.7 Python version: 3.10.8

Detailed description

Using latest opencv-python from pip does not work on Big Sur.

4.6.0.66 works ok.

Symbot not found - using shared library

cv2/cv2.abi3.so, 2): Symbol not found: ZNKSt3115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv

cv2/.dylibs/libjxl.0.7.0.dylib (which was built for Mac OS X 12.0)

Traceback (most recent call last):
  File "/Users/rac/src/tf2-frames/super-slomo/inference.py", line 6, in <module>
    import cv2
  File "/opt/homebrew/Caskroom/miniconda/base/envs/tf2/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/tf2/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/opt/homebrew/Caskroom/miniconda/base/envs/tf2/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dlopen(/Volumes/Extra/miniconda/base/envs/tf2/lib/python3.10/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: __ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv
  Referenced from: /Volumes/Extra/miniconda/base/envs/tf2/lib/python3.10/site-packages/cv2/.dylibs/libjxl.0.7.0.dylib (which was built for Mac OS X 12.0)
  Expected in: /usr/lib/libc++.1.dylib

(tf2) rac@82-181-219-151 blades % 

Steps to reproduce

I don't think this is reproducable on other systems.

Issue submission checklist

icvua commented 1 year ago

I'm having the same issue.

soraew commented 1 year ago

I'm having the same issue as well.

asmorkalov commented 1 year ago

Reproduced with Mac mini M1 with MacOS 11.1:

(base) xperience@xpereince-mini-m1 venv % python3.9 -m venv .  
(base) xperience@xpereince-mini-m1 venv % source ./bin/activate
(venv) (base) xperience@xpereince-mini-m1 venv % pip install --upgrade pip
Requirement already satisfied: pip in ./lib/python3.9/site-packages (21.1.1)
Collecting pip
  Using cached pip-22.3.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.1.1
    Uninstalling pip-21.1.1:
      Successfully uninstalled pip-21.1.1
Successfully installed pip-22.3.1
(venv) (base) xperience@xpereince-mini-m1 venv % pip install opencv-python
Collecting opencv-python
  Using cached opencv_python-4.7.0.68-cp37-abi3-macosx_11_0_arm64.whl (31.1 MB)
Collecting numpy>=1.19.3
  Using cached numpy-1.24.1-cp39-cp39-macosx_11_0_arm64.whl (13.9 MB)
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.24.1 opencv-python-4.7.0.68
(venv) (base) xperience@xpereince-mini-m1 venv % python 
Python 3.9.5 (default, Jun  4 2021, 05:25:09) 
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xperience/asmorkalov/venv/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/Users/xperience/asmorkalov/venv/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/Users/xperience/.pyenv/versions/3.9.5/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dlopen(/Users/xperience/asmorkalov/venv/lib/python3.9/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: __ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv
  Referenced from: /Users/xperience/asmorkalov/venv/lib/python3.9/site-packages/cv2/.dylibs/libjxl.0.7.0.dylib (which was built for Mac OS X 12.0)
  Expected in: /usr/lib/libc++.1.dylib

>>> 
>>> 
>>> quit()
asmorkalov commented 1 year ago

The library is needed for FFmpeg.

anttiryt commented 1 year ago

The library is needed for FFmpeg.

Can you use 4.6 ?

asmorkalov commented 1 year ago

Fixed in 4.7.0.70

BeteAF commented 10 months ago

pip install opencv-python==4.6.0.66 I am using macOS Big Sur 11.5. I tried with 4.7.0.72, but doesn't work, then I tried 4.6.0.66 and it worked

Thoughtyness commented 9 months ago

On macOS BigSur 11.7.10, 4.8.1.78 works, but the next version I can install, 4.9.0.80, reproduces this error.

asmorkalov commented 9 months ago

OpenCV team uses Github Action provided VMs for Mac OS build and Brew packages for dependencies. The last release was done for MasOS 11 x86_64 and MacOS 12 arm64 due to dependencies reason. I'll take a look if we can decrease requirements for the next release, but probability is low.

edsonms commented 7 months ago

I have the same issue on Mac OS Big Sur version 11.7.10

kaustubh2024 commented 7 months ago

I have the same error on Mac Big Sur 11.7.10.

Exact error is this: ImportError: dlopen(/Users/Kaustubh/Library/Python/3.12/lib/python/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: ZNSt3113basic_filebufIcNS_11char_traitsIcEEE4openEPKcj Referenced from: /Users/Kaustubh/Library/Python/3.12/lib/python/site-packages/cv2/.dylibs/libvmaf.1.dylib (which was built for Mac OS X 12.0) Expected in: /usr/lib/libc++.1.dylib

edsonms commented 7 months ago

I have the same error on Mac Big Sur 11.7.10.

Exact error is this: ImportError: dlopen(/Users/Kaustubh/Library/Python/3.12/lib/python/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: ZNSt3113basic_filebufIcNS_11char_traitsIcEEE4openEPKcj Referenced from: /Users/Kaustubh/Library/Python/3.12/lib/python/site-packages/cv2/.dylibs/libvmaf.1.dylib (which was built for Mac OS X 12.0) Expected in: /usr/lib/libc++.1.dylib

If you find a solution let me know. I got exactly the same