That's the error:
Traceback (most recent call last):
File "/Users/Chayma/pythonProject/venv/main.py", line 3, in <module>
from PyQt5 import QtWidgets
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyQt5/QtWidgets.abi3.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyQt5/QtWidgets.abi3.so: mach-o, but wro`enter code here`ng architecture
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyQt5/QtWidgets.abi3.so: mach-o, but wrong architecture
And that is my code:
import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
import PyQt5.QtWidgets as QtWidgets
from PyQt5.QtWidgets import QDialog, QApplication, QWidget
class MainWindow(QDialog):
def __init__(self):
super(MainWindow, self).__init__()
loadUi("helloooo.ui", self)
#main
app = QApplication(sys.argv)
mainwindow = MainWindow()
widget = QtWidgets.QStackedWidget()
widget.addWidget(mainwindow)
widget.setFixedHeight(800)
widget.setFixedWidth(1200)
widget.show()
try:
sys.exit(app.exec_())
except:
print("exit")
It looks like you are using a Mac and I'm guessing it's a M1 Mac. I ran into a similar issue.
It is because PyQt5 does not have a Universal2
build on PyPi.
You could try switching to PyQt6 which has a version for M1 Macs or you install PyQt5 via Brew
Brew PyQt5 which, according to the website, has a M1 build. But I did not test it.