I think I did everything I could in the last 24 hours, but nothing seems to work. I have a python script I'd like to create a Mac OS X App Bundles from. I run pyinstaller
with the following options:
pyinstaller --onefile --windowed --exclude-module matplotlib test.py
. Everything seems fine (the output is mostly INFO messages with a couple of dyld: warnings). However, when I try to execute the app it immediately closes. Attempt to run generated UNIX executable script test
fails with the following error:
objc[24785]: Class RunLoopModeTracker is implemented in both /var/folders/gd/b5gj1m4x09b6jpb1llxk4vlr0000gn/T/_MEIOWkdrF/QtCore and /usr/local/Cellar/qt/5.9.1/lib/QtCore.framework/Versions/5/QtCore. One of the two will be used. Which one is undefined.
objc[24785]: Class NotificationReceiver is implemented in both /var/folders/gd/b5gj1m4x09b6jpb1llxk4vlr0000gn/T/_MEIOWkdrF/QtWidgets and /usr/local/Cellar/qt/5.9.1/lib/QtWidgets.framework/Versions/5/QtWidgets. One of the two will be used. Which one is undefined.
objc[24785]: Class QCocoaPageLayoutDelegate is implemented in both /var/folders/gd/b5gj1m4x09b6jpb1llxk4vlr0000gn/T/_MEIOWkdrF/QtPrintSupport and /usr/local/Cellar/qt/5.9.1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport. One of the two will be used. Which one is undefined.
objc[24785]: Class QCocoaPrintPanelDelegate is implemented in both /var/folders/gd/b5gj1m4x09b6jpb1llxk4vlr0000gn/T/_MEIOWkdrF/QtPrintSupport and /usr/local/Cellar/qt/5.9.1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport. One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7f9dbdbb8400) is not the object's thread (0x7f9dbbd8bc20).
Cannot move to target thread (0x7f9dbdbb8400)
You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
This application failed to start because it could not find or load the Qt platform plugin "cocoa"
in "".
Available platform plugins are: cocoa, minimal, offscreen.
Reinstalling the application may fix this problem.
Abort trap: 6
logout
Saving session...completed.
[Process completed]
A bit more info:
Mac OS X: 10.11.6
Python: 2.7.13
qt: stable 5.9.1 (bottled) (via brew)
pyqt: stable 5.9 (bottled) (via brew)
pyinstaller: 3.3 (via pip)
The script test.py
reads data from xlsx
spreadsheet (openpyxl
) and creates multiple .docx
files based on the provided template (docxtpl
). It has simple interface design.py
that was converted to .py
from .ui
via pyuic5
.
What am I doing wrong? (or what am I not doing?) What can cause such problem?
My attempts to fix it:
At first, I didn't exclude matplotlib
but it resulted in RuntimeError:
RuntimeError: Path in environment MATPLOTLIBDATA not a directory
[26131] Failed to execute script test
Also, I thought that the error with two sets of qt plugins maybe due to the existence of Qt4. I had a complete mess with Qt installations. There was brew's qt5
(built with python2) and another macports's qt5-mac
plus qt4-mac
. I uninstalled qt4-mac
and deactivated qt5-mac
, but it didn't help.
I reinstalled qt
, pyqt
and pyinstaller
to make sure that all of them were built with python 2.7
.
Before switching to pyinstaller
I tried py2app
. At first, I used py2applet --make-setup test.py
to create a setup file. Again, build went normal, but the execution failed. Running from the console (dist/test.app/Contents/MacOS/MyApp
) revealed that some libraries are missing: ImportError: No module named docxtpl
. Adding pyqt packages python setup.py py2app -A --packages=PyQt5
didn't help as well. Manually adding OPTIONS = {'argv_emulation': True, 'includes':['sip','PyQt5','PyQt5.QtWidgets']}
to setup.py
did no difference too.
Another set of qt plugins are located in /var/folders/
which is the location for per-user temporary files and caches. Don't know how exactly OS X manages this, but know that it's safe to clean it. So I did, however, cleaning /var/folders/gd
before building or/and running does nothing. Cashed folder reappears and interferes with qt's plugins. Not sure, that this is the root of the problem, but have no more ideas how to fix it.