4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenCV使用時にQt platform plugin "xcb"エラーで動画が出ない場合

Last updated at Posted at 2022-09-12

行いたかった作業:OpenCVをつかうプログラムを動かしたい(YOLOX)

2024年10月
同一エラー、Opencv絡みで類似症状がでたので改善策を追記

1. エラー表示

  • エラー表示はこの表示で始まっています。
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.

  • その下に〇〇といったplatform pluginsは使えるけど云々、最終的に再インストールを促すような表示になっています。

    • 多くの方が検索して以下のような記事を見つけて解決されている方も多いかと思います。

2. 参考にした記事等

  • 私の場合は残念ながらすべて解決しませんでした・・・

  • 変数の変更や不足、設定変更(OpenCV)

  • 最終目的はOpenCVでの描画だったのですが、今回は残念ながら解決に至りませんでした。

  • aptで不足パッケージの追加や再インストール


  • condaでパッケージを再インストール


2. 私の場合の解決策

  • 動作させていたのはYOLOX でエラーはQtがらみでもあり、OpenCV絡みでもある。

    • Qtはいろんな方法で再インストールやパス変更をしたけど、解決せず。
    • こうなれば OpenCVか??
  • インストール済みOpencv-pythonのバージョンが 4.5.5.62

    • アンインストールして、徐々にバージョンを下げてみる。
opencv-python入れ直し


# 4.5.5.64(元のバージョン)
# 改善せず
# 4.5.5.62
pip uninstall opencv-python


# 動作したバージョン
pip install==4.5.4.60

  • 画像はコンプライアンスにかかってしまうので、動作している画面だけ載せます(一部塗りつぶし)
    Screenshot from 2022-09-12 16-05-02.png

3. 今回もOpencvのアプリ作成

  • ただし動画は再生しません
  • でもOpencvを使用するアプリでかつPyQt5使用

ターミナル画面

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/xxxxx/anaconda3/envs/anoma/lib/python3.8/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, linuxfb, minimal, offscreen, vnc, webgl

エラーにxcbの処理にOpencvがまたしても・・・

resolution
In this case, failure cause is opencv-python-headless.
After uninstalled it, my application is working well.

pip list |grep open
opencv-python                        4.7.0.72
opencv-python-headless               4.7.0.72 <---kore
  • 度々邪魔をしてくれていたheadlessを見つけたのでアンインストール
  • 無事にアプリが起動してくれました

上記方法でもインストールしない場合

  • This application failed to start because no Qt platform plugin could be initialized. Reinstalling
  • このエラーがで続けている
  • Plugin is whatな場合
ターミナル画面

pip install PyQt5-tool

まとめ
エラーの表示も大事ですが、何をしているかも考える必要性を感じました。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?