Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This application failed to start because no Qt platform plugin could be initialized #1220

Open
haithienld opened this issue Nov 29, 2022 · 13 comments

Comments

@haithienld
Copy link

Provide environment information

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/pidl/.local/lib/python3.9/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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.

What OS are you using?

Ubuntu 20.04

Describe the Bug

When I run labelme Folder. The bug happens

Expected Behavior

No response

To Reproduce

No response

@haithienld
Copy link
Author

I fixed it.
After deleting all in the /home/pidl/.local/lib/python3.9/site-packages/cv2/qt/plugins folder that the bug still happens.
Please install. (with opencv-4.4)
sudo apt-get install qt5-default

@amaizr
Copy link

amaizr commented Jan 3, 2023

was able to work around this using this answer: NVlabs/instant-ngp#300 (comment)

@wkentaro wkentaro pinned this issue Feb 7, 2023
@kaiesalmahmud
Copy link

kaiesalmahmud commented Mar 13, 2023

I was facing the same issue. Turns out in my case, python 3.9 was causing this conflict.
I managed to solve this by creating a new environment with python 3.8.

commands:
conda create -n myenv python=3.8.0
conda activate myenv
pip3 install opencv-python==4.2.0.34

@a-pijpaert
Copy link

For me it worked to downgrade PyQt5 to version 5.13.2.

I am on Python version 3.10.6 and opencv-python version 4.7.0.72.

@bryanbocao
Copy link

pip install --upgrade pyqt5_tools

solved my issue.
Reference
https://github.com/fmjohnson97/habitat_heuristic/issues/2#issuecomment-1751440118

@kimkimyoung
Copy link

kimkimyoung commented Dec 21, 2023

pip install opencv-python-headless

It works for me in a conda env

@sc0v0ne
Copy link

sc0v0ne commented Dec 21, 2023

Use brew, which avoids these errors. On Ubuntu brew works.

brew install pyqt 
brew install wkentaro/labelme/labelme  # command line interface

@Jie-Huangi
Copy link

pip install opencv-python-headless

It works for me in a conda env
also sloved my issue, thanks.

@Satyam-Vy
Copy link

pip install opencv-python-headless

It works for me in a conda env

worked for me to solve anaconda-navigator launch issue! thanks!!

@mzohaibnasir
Copy link

pip install opencv-python-headless
It works for me in a conda env

worked for me to solve anaconda-navigator launch issue! thanks!!

that didn't work but
upgrading openv did the job for me
pip install opencv-python --upgrade

@Troye5585
Copy link

New system ubuntu 20.04, first time installing labelImg with a bug:
(labelimg) user@sf-purechip-gpu:~$ labelImg
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" 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: linuxfb, minimal, offscreen, vnc, webgl, xcb.

已放弃 (核心已转储)
Solution Methods
1:export QT_DEBUG_PLUGINS=1
2:get the response: Cannot load library /home/user/anaconda3/envs/labelimg/lib/python3.8/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: 无法打开共享对象文件: 没有那个文件或目录)
3: run in dir /home/user/anaconda3/envs/labelimg/lib/python3.8/site-packages/PyQt5/Qt5/plugins/platforms/ "ldd libqxcb.so" to get "libxcb-xinerama.so.0 => not found"
4: sudo apt-get install libxcb-xinerama0
5: labelImg
6: OK
refer to: https://cloud.tencent.com/developer/article/1726400

@ichsan2895
Copy link

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" 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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

This problem solved when I install newer PyQt5, PyQt5-Qt5:

pip install PyQt5-Qt5==5.15.16 pyqt5==5.15.11

Tested on Python 3.9.16 and labelme 5.6.0

@javierselva
Copy link

Ok, this took me a while. None of the solutions here fully worked for me, so a summary of what I had to do, based on previous comments.

I am on Ubuntu 24.04.2, with Miniconda 25.1.1.

I started a brand new conda environment with the python version 3.10.6 (as suggested by @a-pijpaert).

conda create -n myenv python==3.10.6
conda activate myenv

Installed opencv and pyqt using pip3. Then installed labelme (also with pip3).

pip3 install opencv-python==4.11.0.86
pip3 install pyqt5==5.15.9
pip3 install labelme

Then, following @bryanbocao 's advice:

pip install --upgrade pyqt5_tools

Then install opencv headless (for good measure):
pip3 install opencv-python-headless

Make sure to remove "CONDA_HOME/envs/myenv/lib/python3.10/site-packages/cv2/qt/plugins" (as @haithienld suggested). In this thread they say that this will break OpenCV for some applications, that's why I thought using the headless version may be worth a try. Anyway, in my case I am using this environment just for labelme.

As per here do:
sudo apt-get install pyqt5-dev-tools

And, as per here, add the code between the dashed lines to "CONDA_HOME/envs/labeling/lib/python3.10/site-packages/labelme/app.py"

from labelme.widgets import LabelListWidgetItem
from labelme.widgets import ToolBar
from labelme.widgets import UniqueLabelQListWidget
from labelme.widgets import ZoomWidget

#-----------------------------
from PyQt5.QtCore import QLibraryInfo
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = QLibraryInfo.location(
    QLibraryInfo.PluginsPath
)
#-----------------------------

# FIXME
# - [medium] Set max zoom value to something big enough for FitWidth/Window

# TODO(unknown):
# - Zoom is too "steppy".

After that, it all worked for me. I'm not 100% sure all the steps are necessary, but they are what led me to here.

In summary, and in case everything else fails, these are the versions which appear in my conda environment where it now works. Note that all of them were installed with pip, not with conda:

labelme                   5.6.1                    pypi_0    pypi
numpy                     1.26.4                   pypi_0    pypi
opencv-python             4.11.0.86                pypi_0    pypi
opencv-python-headless    4.11.0.86                pypi_0    pypi
pyqt5                     5.15.9                   pypi_0    pypi
pyqt5-plugins             5.15.9.2.3               pypi_0    pypi
pyqt5-qt5                 5.15.2                   pypi_0    pypi
pyqt5-sip                 12.17.0                  pypi_0    pypi
pyqt5-tools               5.15.9.3.3               pypi_0    pypi
python                    3.10.6               haa1d7c7_1  
qt5-applications          5.15.2.2.3               pypi_0    pypi
qt5-tools                 5.15.2.1.3               pypi_0    pypi
qtpy                      2.4.3                    pypi_0    pypi

The numpy version is from an old attempt (I was having a separate issue where labelme was complaining and required numpy<2.0, I leave it here just in case some else has the same issue), but after replicating my own steps in a new environment I have numpy==2.2.3 without issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests