New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This application failed to start because it could not find or load the Qt platform plugin "cocoa" in "". #2924

Closed
goodryb opened this Issue Oct 17, 2017 · 7 comments

Comments

Projects
None yet
6 participants
@goodryb

goodryb commented Oct 17, 2017

Hi pyInstaller!

This error happens when running the app produced by pyinstaller.

I'm using Python 3.6.2 、 PyInstaller 3.4.dev0+133d18156 on MacOS 10.13

when I run cmd: python3 test.py , it worked

$sudo pyinstaller -F -c --debug test.py
159 INFO: PyInstaller: 3.4.dev0+133d18156
159 INFO: Python: 3.6.2
174 INFO: Platform: Darwin-17.0.0-x86_64-i386-64bit
176 INFO: wrote /Users/goodryb/PycharmProjects/aliyunUI/src/test.spec
188 INFO: UPX is available.
193 INFO: Extending PYTHONPATH with paths
['/Users/goodryb/PycharmProjects/aliyunUI/src',
 '/Users/goodryb/PycharmProjects/aliyunUI/src']
193 INFO: checking Analysis
193 INFO: Building Analysis because out00-Analysis.toc is non existent
194 INFO: Initializing module dependency graph...
198 INFO: Initializing module graph hooks...
202 INFO: Analyzing base_library.zip ...
5568 INFO: running Analysis out00-Analysis.toc
5583 INFO: Caching module hooks...
5592 INFO: Analyzing /Users/goodryb/PycharmProjects/aliyunUI/src/test.py
5619 INFO: Loading module hooks...
5619 INFO: Loading module hook "hook-PyQt5.py"...
5776 INFO: Loading module hook "hook-encodings.py"...
5899 INFO: Loading module hook "hook-PyQt5.Qt.py"...
5902 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
5904 INFO: Loading module hook "hook-xml.py"...
6313 INFO: Loading module hook "hook-pydoc.py"...
6314 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
6471 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
7156 INFO: Loading module hook "hook-PyQt5.QtPrintSupport.py"...
7294 INFO: Looking for ctypes DLLs
7294 INFO: Analyzing run-time hooks ...
7298 INFO: Including run-time hook 'pyi_rth_qt5.py'
7320 INFO: Looking for dynamic libraries
7816 INFO: Looking for eggs
7816 INFO: Using Python library /usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/Python
7820 INFO: Warnings written to /Users/goodryb/PycharmProjects/aliyunUI/src/build/test/warntest.txt
7858 INFO: Graph cross-reference written to /Users/goodryb/PycharmProjects/aliyunUI/src/build/test/xref-test.html
7878 INFO: checking PYZ
7879 INFO: Building PYZ because out00-PYZ.toc is non existent
7879 INFO: Building PYZ (ZlibArchive) /Users/goodryb/PycharmProjects/aliyunUI/src/build/test/out00-PYZ.pyz
8380 INFO: Building PYZ (ZlibArchive) /Users/goodryb/PycharmProjects/aliyunUI/src/build/test/out00-PYZ.pyz completed successfully.
8390 INFO: checking PKG
8390 INFO: Building PKG because out00-PKG.toc is non existent
8390 INFO: Building PKG (CArchive) out00-PKG.pkg
19685 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
19692 INFO: Bootloader /usr/local/lib/python3.6/site-packages/PyInstaller/bootloader/Darwin-64bit/run_d
19692 INFO: checking EXE
19692 INFO: Building EXE because out00-EXE.toc is non existent
19693 INFO: Building EXE from out00-EXE.toc
19693 INFO: Appending archive to EXE /Users/goodryb/PycharmProjects/aliyunUI/src/dist/test
19752 INFO: Fixing EXE for code signing /Users/goodryb/PycharmProjects/aliyunUI/src/dist/test
19779 INFO: Building EXE from out00-EXE.toc completed successfully.

when running the app : open test.app

……
dyld: loaded: /usr/local/Cellar/qt/5.9.1/plugins/platforms/libqcocoa.dylib
dyld: loaded: /usr/local/Cellar/qt/5.9.1/lib/QtGui.framework/Versions/5/QtGui
dyld: loaded: /usr/local/Cellar/qt/5.9.1/lib/QtCore.framework/Versions/5/QtCore
dyld: loaded: /usr/local/Cellar/qt/5.9.1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport
dyld: loaded: /usr/local/Cellar/qt/5.9.1/lib/QtWidgets.framework/Versions/5/QtWidgets
objc[99235]: Class RunLoopModeTracker is implemented in both /var/folders/ks/5f8mgk0s18v3vvtm6fcwjrvr0000gn/T/_MEI2AAEmc/QtCore (0x104c4d010) and /usr/local/Cellar/qt/5.9.1/lib/QtCore.framework/Versions/5/QtCore (0x108cdf010). One of the two will be used. Which one is undefined.
objc[99235]: Class NotificationReceiver is implemented in both /var/folders/ks/5f8mgk0s18v3vvtm6fcwjrvr0000gn/T/_MEI2AAEmc/QtWidgets (0x105bdb218) and /usr/local/Cellar/qt/5.9.1/lib/QtWidgets.framework/Versions/5/QtWidgets (0x1091f7218). One of the two will be used. Which one is undefined.
objc[99235]: Class QCocoaPageLayoutDelegate is implemented in both /var/folders/ks/5f8mgk0s18v3vvtm6fcwjrvr0000gn/T/_MEI2AAEmc/QtPrintSupport (0x105dfaef0) and /usr/local/Cellar/qt/5.9.1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x105ec7ef0). One of the two will be used. Which one is undefined.
objc[99235]: Class QCocoaPrintPanelDelegate is implemented in both /var/folders/ks/5f8mgk0s18v3vvtm6fcwjrvr0000gn/T/_MEI2AAEmc/QtPrintSupport (0x105dfaf40) and /usr/local/Cellar/qt/5.9.1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x105ec7f40). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7fe0a4d04090) is not the object's thread (0x7fe0a4fa3ae0).
Cannot move to target thread (0x7fe0a4d04090)

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.
[1]    99234 abort      ./test

the spec file

# -*- mode: python -*-

block_cipher = None

a = Analysis(['test.py'],
             pathex=['/Users/goodryb/PycharmProjects/aliyunUI/src'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='test',
          debug=True,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )

in warntest.txt I find many missing module,such as

missing module named nt - imported by os, ntpath, shutil, /Users/goodryb/PycharmProjects/aliyunUI/src/test.py
missing module named msvcrt - imported by subprocess, /Users/goodryb/PycharmProjects/aliyunUI/src/test.py, getpass
missing module named _winapi - imported by subprocess, /Users/goodryb/PycharmProjects/aliyunUI/src/test.py
missing module named _dummy_threading - imported by dummy_threading, /Users/goodryb/PycharmProjects/aliyunUI/src/test.py

the app code

from PyQt5 import QtWidgets

class MyWindow(QtWidgets.QWidget):
    def __init__(self):
        super(MyWindow, self).__init__()
        self.myButton = QtWidgets.QPushButton(self)
        self.myButton.setObjectName("myButton")
        self.myButton.setText("Test")


if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    myshow = MyWindow()
    myshow.show()
    sys.exit(app.exec_())
@htgoebel

This comment has been minimized.

Member

htgoebel commented Oct 17, 2017

This looks like not all required files are packages. Please have a look at Make sure everything is packaged correctly for tips to find out what is missing.

@goodryb

This comment has been minimized.

goodryb commented Oct 17, 2017

@htgoebel

I create a new python3 env by virtualenv ,and use the option --no-site-packages,then I install the package pyqt5、pyinstaller 3.4.dev0+133d18156

build cmd : pyinstaller --onedir -c --debug test.py

when I execute ./test in dist/test directory ,it still output the same error message

I install python3 by brew, the path is /usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/bin/python3.6

so I think is there a problem between python3 and pyinstaller

@htgoebel

This comment has been minimized.

Member

htgoebel commented Oct 17, 2017

As I said: Please have a look at Make sure everything is packaged correctly for tips to find out what is missing. Do not expect somebody else is debugging this for you, even if it may be a "common" problem.

@dvj

This comment has been minimized.

dvj commented Nov 8, 2017

This is the same issue as #2857, just a different platform. The fix is the same as presented there. After applying 59a2330 the Qt app works without issue.

@mherrmann

This comment has been minimized.

Contributor

mherrmann commented Dec 7, 2017

I am experiencing the same problem (macOS, PyInstaller 3.3, PyQt 5.6.2, Python 3.5.3). Applying 082078e and 59a2330 fixes the issue for me.

@bjones1

This comment has been minimized.

Member

bjones1 commented Jan 31, 2018

I'm closing this, since #3233 should fix it -- see the instructions there.

@bjones1 bjones1 closed this Jan 31, 2018

@melMass

This comment has been minimized.

melMass commented Feb 19, 2018

Same as @mherrmann these fixes work here.

edit: also I tried @bjones1 branch #3233 but it failed. Would love to have a fix in master ;)

@htgoebel htgoebel added this to the PyInstaller 3.4 milestone Sep 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment