pyqt5 python not working.

Hello, I decided to try out the pyqt5 library on this site, I imported the required libraries and ran the code:

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
class App(QWidget):
    def __init__(self):
        self.title = 'PyQt5 button -'
        self.left = 10 = 10
        self.width = 320
        self.height = 200
    def initUI(self):
        self.setGeometry(self.left,, self.width, self.height)
        button = QPushButton('PyQt5 button', self)
        button.setToolTip('This is an example button')

    def on_click(self):
        print('PyQt5 button click')
if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = App()

After that I got this error:

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.

SIGABRT: abort
PC=0x7f0df9432bc7 m=0 sigcode=18446744073709551610
signal arrived during cgo execution

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x4bff40, 0xc000064cd8)
runtime/cgocall.go:158 +0x5c fp=0xc000064cb0 sp=0xc000064c78 pc=0x4068dc
main._Cfunc_pry_eval_file(0x5555560d7c70, 0x555556196900, 0x1, 0x555556199c20)
_cgo_gotypes.go:586 +0x4c fp=0xc000064cd8 sp=0xc000064cb0 pc=0x4bdbac
main.Python.EvalFile.func5(0x555556199c20?, 0x8?, {0xc0001a2170?, 0x0, 0x40d235?}, 0x0?) +0x75 fp=0xc000064d28 sp=0xc000064cd8 pc=0x4bec15
main.Python.EvalFile({}, {0x7fff2a3dec7a, 0x7}, {0xc0001a2170, 0x0, 0x0}) +0x20c fp=0xc000064de0 sp=0xc000064d28 pc=0x4be9ec
main.(*Python).EvalFile(0x7f0dd00cfec0?, {0x7fff2a3dec7a?, 0x5d6a60?}, {0xc0001a2170?, 0x0?, 0xc00019e8f0?})
:1 +0x45 fp=0xc000064e18 sp=0xc000064de0 pc=0x4bf9c5{{0x50dec8?, 0x5d6a60?}, {0x7fff2a3dec64?, 0xc0001920f0?}}, {0x7fff2a3dec7a, 0x7}, {0xc0001a2170, 0x0, 0x0}) +0xa2 fp=0xc000064e78 sp=0xc000064e18 pc=0x4bc842{0x50dec8, 0x5d6a60}) +0x2f3 fp=0xc000064f60 sp=0xc000064e78 pc=0x4bd1b3
main.main() +0x27 fp=0xc000064f80 sp=0xc000064f60 pc=0x4bd327
runtime/proc.go:250 +0x212 fp=0xc000064fe0 sp=0xc000064f80 pc=0x438cb2
runtime/asm_amd64.s:1594 +0x1 fp=0xc000064fe8 sp=0xc000064fe0 pc=0x465061

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
runtime/proc.go:363 +0xd6 fp=0xc000056fb0 sp=0xc000056f90 pc=0x439076
runtime/proc.go:302 +0xad fp=0xc000056fe0 sp=0xc000056fb0 pc=0x438f0d
runtime/asm_amd64.s:1594 +0x1 fp=0xc000056fe8 sp=0xc000056fe0 pc=0x465061
created by runtime.init.6
runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
runtime/proc.go:363 +0xd6 fp=0xc000057790 sp=0xc000057770 pc=0x439076
runtime/mgcsweep.go:278 +0x8e fp=0xc0000577c8 sp=0xc000057790 pc=0x42610e
runtime/mgc.go:178 +0x26 fp=0xc0000577e0 sp=0xc0000577c8 pc=0x41afc6
runtime/asm_amd64.s:1594 +0x1 fp=0xc0000577e8 sp=0xc0000577e0 pc=0x465061
created by runtime.gcenable
runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc0000320e0?, 0x50d320?, 0x1?, 0x0?, 0x0?)
runtime/proc.go:363 +0xd6 fp=0xc000057f70 sp=0xc000057f50 pc=0x439076
runtime/mgcscavenge.go:389 +0x53 fp=0xc000057fa0 sp=0xc000057f70 pc=0x4241b3
runtime/mgcscavenge.go:617 +0x45 fp=0xc000057fc8 sp=0xc000057fa0 pc=0x424785
runtime/mgc.go:179 +0x26 fp=0xc000057fe0 sp=0xc000057fc8 pc=0x41af66
runtime/asm_amd64.s:1594 +0x1 fp=0xc000057fe8 sp=0xc000057fe0 pc=0x465061
created by runtime.gcenable
runtime/mgc.go:179 +0xaa

goroutine 18 [finalizer wait]:
runtime.gopark(0x5a82c0?, 0xc0001861a0?, 0x0?, 0x0?, 0xc000056770?)
runtime/proc.go:363 +0xd6 fp=0xc000056628 sp=0xc000056608 pc=0x439076
runtime/mfinal.go:180 +0x10f fp=0xc0000567e0 sp=0xc000056628 pc=0x41a0cf
runtime/asm_amd64.s:1594 +0x1 fp=0xc0000567e8 sp=0xc0000567e0 pc=0x465061
created by runtime.createfing
runtime/mfinal.go:157 +0x45

rax 0x0
rbx 0x28e
rcx 0x7f0df9432bc7
rdx 0x6
rdi 0x28e
rsi 0x28e
rbp 0x7fff2a3dd950
rsp 0x7fff2a3dd500
r8 0x7
r9 0x555556389340
r10 0x8
r11 0x246
r12 0x555556169560
r13 0x555556386d30
r14 0x6
r15 0x7fff2a3dd960
rip 0x7f0df9432bc7
rflags 0x246
cs 0x33
fs 0x0
gs 0x0
repl process died unexpectedly: exit status 2

try after running in shell

sed -i 's/];/  pkgs.xorg.libxcb\n  &/' replit.nix

This happened because the application was incorrectly installed, as stated by:
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.
That is, please attempt to reinstall. You can do so by:

  1. go to package manager and uninstall pyqt by finding that module and pressing the - button and then typing in pyqqt and pressing the + button
  2. alternatively go to shell and type in pip uninstall pyqt -y; pip install pyqt
  3. OR go to shell and type pip install --upgrade pyqt
  4. OR go to shell and type poetry remove pyqt; poetry add pyqt

Here is an example repl using pyqt I have found, hope it helps :smiley:

Also, as @sonicx180 would say, Welcome to the community! have a nice coding journey and come to us with any questions

potential solution and nice fallback list but would never recommend a blind pip install --upgrade because it could break the code. I would do

pip install --force-reinstall pyqt

Although imo this doesn’t seem like a corruption issue that would be solved by reinstalling given that I’ve seen people have this issue numerous times :man_shrugging: Worth a try after also trying

sed -i 's/];/  pkgs.xorg.xcbutil\n  &/' replit.nix
1 Like

Ah yes thank you for correcting me :smiley: