Py2App crashes on launch says it cannot load Qt platform plugin "cocoa" even when found

Viewed 120

I have built a python program with a GUI (PyQt5) and wanted to make it into an .app for macOS. I have chosen Py2App to do this.

When creating a .app with Alias Mode in Py2App the app works fine, however, when I create the bundled version of the app, the app tries to launch but crashes.

I tried opening this app from the terminal and got this error:

(planner_venv) Febins-MacBook-Pro:v1.2 - Planner Builder Febin.J$ ./dist/Planner\ Builder.app/Contents/MacOS/Planner\ Builder 
qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" 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: cocoa, minimal, offscreen, webgl.

Abort trap: 6

I tried reinstalled PyQt5 using the code below:

python3 -m pip install --upgrade --force-reinstall PyQt5

After this, I still get the same error.

I am using Python 3.10.1. Py2App 0.26.1. PyQt5 5.15.6. I am MacOS 12.1

This is my setup.py

"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['main_window.py']
DATA_FILES = ["both_bins.png", "both_holidays.png", "green_bin.png", "s_holidays.png", "u_holidays.png", "event_dates.db"]
OPTIONS = {
"iconfile":"logo.icns",
"plist": {
'CFBundleName': "Planner Builder",
'CFBundleDisplayName': "Planner Builder",
'CFBundleVersion': "1.1",
'CFBundleShortVersionString': "1.1"
}
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)

Could you please help me solve this error?

0 Answers
Related