简体   繁体   中英

Python cv2.imshow() crashes with Abort trap: 6

My code:

import cv2
print(cv2.__version__)
img = cv2.imread("img.jpg")
print(len(img))
print("now showing")
cv2.imshow("img",img)
cv2.waitkey(0)

I have also tried waitkey(1) but the error seems to occure at the cv2.imshow line (6th)

Error trace:

objc[73658]: Class RunLoopModeTracker is implemented in both /Users/j/opt/anaconda3/lib/python3.7/site-packages/cv2/.dylibs/QtCore (0x110aca7f0) and /Users/j/opt/anaconda3/lib/libQt5Core.5.9.7.dylib (0x128e18a80). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7f80b2434fa0) is not the object's thread (0x7f80b244ec40).
Cannot move to target thread (0x7f80b2434fa0)

You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: cocoa, minimal, offscreen.

Abort trap: 6

I ran into the same issue and found a solution.

  1. pip uninstall opencv-python or opencv-contrib-python

  2. pip install opencv-python-headless

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM