python - Python cv2.imshow() 因中止陷阱而崩溃:6
问题描述
我的代码:
import cv2
print(cv2.__version__)
img = cv2.imread("img.jpg")
print(len(img))
print("now showing")
cv2.imshow("img",img)
cv2.waitkey(0)
我也尝试过waitkey(1)
,但错误似乎发生在cv2.imshow
第 6 行
错误跟踪:
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
解决方案
我遇到了同样的问题并找到了解决方案。
pip 卸载 opencv-python 或 opencv-contrib-python
pip install opencv-python-headless
推荐阅读
- python - TERM 环境变量未设置错误 Python
- javascript - 等待未在 esprima 4.0.1 中解析
- php - Laravel 5.7多个外键引用同一个表主键
- angular - 将服务响应映射到组件模型以显示在视图上
- ruby-on-rails - 消息:失败/错误:需要 File.expand_path('../../config/environment', __FILE__)
- javascript - 无法通过 Angular 组件中的 Promises 赋值
- angular - Angular MatTable - 视口内的中心可扩展行
- java - 模拟静态方法时出现内容类型错误
- excel - 将处理限制到某些单元格
- reactjs - 有人可以告诉我反应 Js 中子元素的这种循环实现有什么问题吗