Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1247

Python • Running a PyQt5 script from command line

$
0
0
Python3.9
Made a simple window with PyQt5.

Code:

import sysfrom PyQt5.QtWidgets import QApplication, QWidgetapp = QApplication(sys.argv)window = QWidget()window.show()app.exec()
Able to run in from Geany and QTDesigner.

When I run it from the command line I get

Code:

b5@b5:~ $ python --versionPython 3.9.2b5@b5:~ $ python t1.pyFailed to create wl_display (No such file or directory)qt.qpa.plugin: Could not load the Qt platform plugin "wayland" 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, xcb.
Installed Python3.12.4. Now I get

Code:

b5@b5:~ $ python3 --versionPython 3.12.4b5@b5:~ $ python3 t1.pyTraceback (most recent call last):  File "/home/b5/t1.py", line 2, in <module>    from PyQt5.QtWidgets import QApplication, QWidgetModuleNotFoundError: No module named 'PyQt5'
also complains that SSL module is not available.

If I could just get it working on 3.9, I can deal with 3.12 later (or not even worry about it).

In case it is relevant:
3.9 is in /usr/bin
3.12 is in /usr/local/bin

Statistics: Posted by evanmars — Thu Jun 27, 2024 7:37 pm



Viewing all articles
Browse latest Browse all 1247

Trending Articles