PyQt fails on MacOS (Apple silicon)
Unsolved
Qt for Python
-
I finally decided to give PyQt a chance to replace Tkinter today, but it's not going well. I'm on a MacBook Air with M2 chip, MacOS 14.4.1, Python 3.12. I did "pip install pyqt5" and "pip install pyqt5-tools"and then tried the program below. It ran with no error messages but did not produce a window. So I upgraded to PyQt6, but the pip install pyqt-toolsgot stuck on these few lines of output:
Collecting pyqt6-tools Downloading pyqt6_tools-6.1.0.3.2-py3-none-any.whl.metadata (8.3 kB) Collecting pyqt6==6.1.0 (from pyqt6-tools) Downloading PyQt6-6.1.0.tar.gz (946 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 946.9/946.9 kB 4.9 MB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... -
Ctl-C did no good. I had to open another terminal session totry my program and got the same result: no errors, no window. Any suggestions?
My starter program.
from PyQt5 import QtWidgets from PyQt5.QtWidgets import QApplication, QMainWindow import sys def window(): xpos = 200 ypos = 200 width = 300 height = 300 app = QApplication(sys.argv) win = QMainWindow() win.setGeometry(xpos, ypos, width, height) win.setWindowTitle("Tech with Tim") # Contents win.show() sys.exit(app.exit()) if __name__ == "__main__": window()
-
Hi
It's
app.exec()
that you should use. Your call toapp.exit()
stops the application before it can start.