PyQT5 could not load the Qt platform plugin “xcb”
-
I am using the same code but with different libraries.
The code with PyQt5
import sys from PyQt5.QtWidgets import QApplication, QWidget if __name__ == '__main__': app = QApplication(sys.argv) w = QWidget() w.resize(250, 150) w.move(300, 300) w.setWindowTitle('Simple') w.show() sys.exit(app.exec_())
The code with PySide2
import sys from PySide2.QtWidgets import QApplication, QWidget if __name__ == '__main__': app = QApplication(sys.argv) w = QWidget() w.resize(250, 150) w.move(300, 300) w.setWindowTitle('Simple') w.show() sys.exit(app.exec_())
The code works fine when using
PySide2
but the following error comes when usingPyQt5
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)
PS: Trust me I have tried everything. Like reinstalling pyqt5 and qt5 framework
OS: Linux h3ll 5.3.12-1-MANJARO #1 SMP PREEMPT Thu Nov 21 10:55:53 UTC 2019 x86_64 GNU/Linux
QT Version: 5.12 -
I am using the same code but with different libraries.
The code with PyQt5
import sys from PyQt5.QtWidgets import QApplication, QWidget if __name__ == '__main__': app = QApplication(sys.argv) w = QWidget() w.resize(250, 150) w.move(300, 300) w.setWindowTitle('Simple') w.show() sys.exit(app.exec_())
The code with PySide2
import sys from PySide2.QtWidgets import QApplication, QWidget if __name__ == '__main__': app = QApplication(sys.argv) w = QWidget() w.resize(250, 150) w.move(300, 300) w.setWindowTitle('Simple') w.show() sys.exit(app.exec_())
The code works fine when using
PySide2
but the following error comes when usingPyQt5
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)
PS: Trust me I have tried everything. Like reinstalling pyqt5 and qt5 framework
OS: Linux h3ll 5.3.12-1-MANJARO #1 SMP PREEMPT Thu Nov 21 10:55:53 UTC 2019 x86_64 GNU/Linux
QT Version: 5.12@Gurkirat-Singh said in PyQT5 could not load the Qt platform plugin “xcb”:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
The first port of call for plugins is to run your application with the
QT_DEBUG_PLUGINS
environment variable set to 1 to see what might go wrong when the plugin is loaded.It will come down to how you have installed PyQt vs PySide2, presumably. Compare your output with that environment variable set against, say:
https://www.reddit.com/r/archlinux/comments/bzowkd/pyqt5_fails_to_load_could_not_load_the_qt/
or
https://bbs.archlinux.org/viewtopic.php?id=247030 -
@Denni-0 said in PyQT5 could not load the Qt platform plugin “xcb”:
that and sys.exit(app.exec_( ) ) is the PyQt4 way to implement that line I have used the PyQt5 version below
Can you show where it's specified that it does not apply to PyQt5 ?
For example in the PyQt5 designer documentation, you have the classic:
import sys from PyQt5.QtWidgets import QApplication, QDialog from ui_imagedialog import Ui_ImageDialog app = QApplication(sys.argv) window = QDialog() ui = Ui_ImageDialog() ui.setupUi(window) window.show() sys.exit(app.exec_())
-
@Denni-0 said in PyQT5 could not load the Qt platform plugin “xcb”:
that and sys.exit(app.exec_( ) ) is the PyQt4 way to implement that line I have used the PyQt5 version below
Can you show where it's specified that it does not apply to PyQt5 ?
For example in the PyQt5 designer documentation, you have the classic:
import sys from PyQt5.QtWidgets import QApplication, QDialog from ui_imagedialog import Ui_ImageDialog app = QApplication(sys.argv) window = QDialog() ui = Ui_ImageDialog() ui.setupUi(window) window.show() sys.exit(app.exec_())
-
@Denni-0 , @SGaist
So far as I am aware, there is no difference in behaviour from PyQt4 to PyQt5 with regard tosys.exit(app.exec())
.If you choose not to use
sys.exit(app.exec())
but justapp.exec()
in PyQt5 as you say, could you please explain how you return a process exit code to any caller which is interested in it? Of course you have always been able to omit thesys.exit()
in either PyQt4 or PyQt5, it's just that then you cannot control the exit code. That is the reasonsys.exit()
has always been used....