在使用macOS ARM 64的Python 3.10上执行import cv2
时出现以下Abort trap: 6
错误。
我尝试使用较低版本的opencv-python(4.6.0.66)和最新版本,但仍然不起作用。我还尝试了一些修复方法,例如使用不同的终端和符号链接libssl.dylib
和libcrypto.dylib
到/usr/local/lib
。
> python
Python 3.10.11 (main, May 22 2023, 00:42:58) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Modules/gcmodule.c:115: gc_decref: Assertion "gc_get_refs(g) > 0" failed: refcount is too small
Enable tracemalloc to get the memory block allocation traceback
object address : 0x105a54010
object refcount : 8
object type : 0x1056e3ab8
object type name: type
object repr : <class 'cv2.utils.nested.ExportClassName'>
Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized
Current thread 0x00000001fce51e00 (most recent call first):
Garbage-collecting
File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1176 in create_module
File "<frozen importlib._bootstrap>", line 571 in module_from_spec
File "<frozen importlib._bootstrap>", line 674 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
File "<frozen importlib._bootstrap>", line 1050 in _gcd_import
File "/opt/python/3.10.11/lib/python3.10/importlib/__init__.py", line 126 in import_module
File "/Users/alpha/Python/pv310-3di/lib/python3.10/site-packages/cv2/__init__.py", line 153 in bootstrap
File "/Users/alpha/Python/pv310-3di/lib/python3.10/site-packages/cv2/__init__.py", line 181 in <module>
File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 883 in exec_module
File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
File "<stdin>", line 1 in <module>
Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator (total: 13)
Abort trap: 6
>
1条答案
按热度按时间omjgkv6w1#
我在OpenCV论坛上找到了下面这篇文章:
Opencv causes debug-enabled python interpreter to abort with a refcount error
看起来(至少在我看来是在macOS上)用
--with-pydebug
flag导致错误,我重新编译了没有flag的Python,它现在似乎工作得很好...