Duplicate QT binaries error by OpenCV 4.2.0.32!!

本文详细描述了在使用OpenCV 4.2.0.32版本时遇到的与Qt环境冲突的问题,包括错误信息、问题原因及解决方案。主要问题是由于加载了两套Qt二进制文件导致的,解决方法是卸载并安装较低版本的opencv-python。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Duplicate QT binaries error by OpenCV 4.2.0.32!!

Problem caused by version 4.2.0.32

Problem Description

Error WHEN QT is NOT installed
Error WHEN QT is NOT installed

Error WHEN QT is installed
Error when QT installed

Similar error

qt complaining 2 sets of binaries

objc[4831]: Class RunLoopModeTracker is implemented in both /opt/miniconda3/envs/grapheme/lib/python3.7/site-packages/cv2/.dylibs/QtCore (0x11e1e87f0) and /opt/miniconda3/envs/grapheme/lib/libQt5Core.5.9.7.dylib (0x1a33234a80). One of the two will be used. Which one is undefined.
loaded library "/opt/miniconda3/envs/grapheme/plugins/platforms/libqcocoa.dylib"
QObject::moveToThread: Current thread (0x7fb18afea390) is not the object's thread (0x7fb18f900090).
Cannot move to target thread (0x7fb18afea390)

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.
QObject::moveToThread: Current thread (0x7fb18afea390) is not the object's thread (0x7fb18f900090).
Cannot move to target thread (0x7fb18afea390)

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 "/opt/miniconda3/envs/grapheme/plugins/platforms/" 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 (from /opt/miniconda3/envs/grapheme/plugins/platforms/), minimal (from /opt/miniconda3/envs/grapheme/plugins/platforms/), offscreen (from /opt/miniconda3/envs/grapheme/plugins/platforms/), cocoa, minimal, offscreen.

OpenCV cv2.imshow is not working because of the qt

qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""

This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Solution

I had the same issue after updating opencv - python to 4.2.0.32.

Uninstall opencv-python and install the lower version (e.g pip install opencv-python==4.1.0.25) solves this issue.
### 解决 PyTorch 中 'duplicate keys detected: end2endloss' 引起的更新错误 当遇到 `duplicate keys detected: end2endloss` 错误时,这通常意味着在定义损失函数或优化器的过程中存在重复键名的情况。具体来说,在字典形式的状态保存或加载过程中出现了同一名字的关键字。 为了有效处理这一问题: #### 1. 检查状态字典中的关键字冲突 确保所有自定义模块和预训练模型之间不存在相同名称的参数。可以通过打印出整个模型的状态字典来查找潜在冲突: ```python for name, param in model.named_parameters(): print(name) ``` 如果发现多个组件共享相同的命名空间,则应考虑重命名这些变量以避免混淆[^1]。 #### 2. 修改配置文件或代码逻辑去除冗余设置 有时此问题是由于多次注册同一个钩子或是无意间创建了两个具有相同标识符的对象所造成的。仔细审查项目结构并移除不必要的实例化语句可以解决问题。 #### 3. 使用唯一前缀区分不同部分 对于复杂的多任务或多分支网络架构而言,给各个子网分配独立的名字空间是一种良好的实践方法。例如,在构建 DETR 这样的端到端检测系统时,可为编码器、解码器以及分类头分别加上特定前缀以便更好地管理和维护权重矩阵和其他属性[^3]: ```python encoder = nn.TransformerEncoder(...) decoder = nn.TransformerDecoder(...) classification_head = ClassificationHead(prefix='cls_') ``` 通过上述措施能够有效地防止因重复键而导致的各种异常情况发生,并提高程序稳定性与可读性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值