Could not load the Qt - libqxcb.soがロードされない

2024/06/13
Cover Image for Could not load the Qt - libqxcb.soがロードされない

エラー内容

labelmeという画像認識等に使う画像データのラベル付に使うツールを実行したときに以下のエラーが出力された。

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
loaded library "/home/_user/.local/lib/python3.10/site-packages/cv2/qt/plugins/platforms/libqxcb.so"
QObject::moveToThread: Current thread (0x5bb1dce45160) is not the object's thread (0x5bb1de203cc0).
Cannot move to target thread (0x5bb1dce45160)
 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/_user/.local/lib/python3.10/site-packages/cv2/qt/plugins" 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: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc.
 
[1] 5615 IOT instruction (core dumped)

対処

いろいろな対処方法があったが今回の場合は以下のコマンドで解決した。

pip uninstall opencv-python
pip install opencv-python-headless