0

I am learning to build GUI for python on PyQt5. I got a program which displays the webcam with face detection on GUI with start and stop functions using opencv and pyqt5. But following error is occuring -

mayank@beware-hoax:~/PythonProjects/gui/pyqt5/pyqt5_face_detection$ source /home/mayank/anaconda3/bin/activate
conda activate gui

(base) mayank@beware-hoax:~/PythonProjects/gui/pyqt5/pyqt5_face_detection$ conda activate gui
/home/mayank/anaconda3/envs/gui/bin/python /home/mayank/PythonProjects/gui/pyqt5/pyqt5_face_detection/main_window.py

(gui) mayank@beware-hoax:~/PythonProjects/gui/pyqt5/pyqt5_face_detection$ /home/mayank/anaconda3/envs/gui/bin/python /home/mayank/PythonProjects/gui/pyqt5/pyqt5_face_detection/main_window.py
qt.qpa.xcb: could not connect to display 
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.

Aborted (core dumped)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Mayank Lad
  • 13
  • 1
  • 6
  • ticks should be backticks --> ``` , not -->''' to format code. – Ahmet Feb 04 '20 at 10:31
  • @MayankLad execute: `export QT_DEBUG_PLUGINS=1` and run your script again, what message do you get in that case? – eyllanesc Feb 04 '20 at 10:56
  • @eyllanesc I found this error occurs only when I run application with visual studio code. When I run through ubuntu terminal it works perfectly!! – Mayank Lad Feb 04 '20 at 11:17

1 Answers1

1

This is definitely not the best solution, but I had the same problem of not being able to run from code and it was working fine from the terminal. Anyways, I started vs code with root privileges and I was able to get over this problem and my GUI started. However doing so is not suggested because of security issues and rightly so.

Something like this : How to open Visual Studio Code with admin privileges to make effect of the installed extensions

I think my anaconda folder location might have something to do with this. I hope somebody provides a real answer to this though

sid gupta
  • 11
  • 2