4

When I was building my python standalone app with command python setup.py py2app, the output package fails to start. However, if I build with hot link python setup.py py2app -A, it works fine.

I used PyQt for my app, maybe that causes the problem.

Here's my setup.py:

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['teammaker.py']
DATA_FILES = ['ui.py']
OPTIONS = {'argv_emulation': True, 'includes':['sip','PyQt5','PyQt5.QtWidgets']}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

and here's my crash log.

Please help to find out the problem, thank you!

BXIA
  • 61
  • 6
  • When you run `python setup.py py2app` do you get a bunch of error messages under a heading `Modules not found (unconditional imports):`? This is happening to me, and I'd love to figure out how to fix it. – Steve Mar 23 '16 at 14:29
  • Indeed! Personally I think these modules are not relevant, and there're some online tutorials saying we can just ignore these warnings. Plz tell me if you fix it. Thanks! – BXIA Mar 24 '16 at 16:13
  • The log indicates there was a fatal Qt message, which you might see on standard output when starting your application in a terminal. However, `py2app` is also quite old/outdated and may lack necessary features for PyQt to work, I'd try using something more modern like [PyInstaller](http://www.pyinstaller.org/) instead. – The Compiler Oct 23 '16 at 18:55
  • @TheCompiler Thanks, the point is PyInstaller cannot actually pack .app bundle (if I'm correct), which is better for Mac distribution. – BXIA Dec 04 '16 at 03:32
  • You're not - it can do `.app` bundles just fine, and mentions this on its website (under "Mac-specific features") ;) – The Compiler Dec 04 '16 at 10:03
  • @TheComplier thanks! Last time I checked it still cannot pack .app bundles. You helped me a lot – BXIA Dec 05 '16 at 11:42

1 Answers1

-2

I had a similar problem with my Text Editor. The solution I found here. In short:

  1. Open the boot.py file inside the dist/name_of_your_program.app/Contents/Resources folder in any text editor (Finder might not show the .app file extension).
  2. Find a function def _run()
  3. Under the import statement add the following line:

    sys.path = [os.path.join(os.environ['RESOURCEPATH'], 'lib', 'python2.6', 'lib-dynload')] + sys.path

You need to change the 'python2.6' into the actual Python version you use. 'python3' worked for me.

  • 2
    If you post a link as part of your answer, you should copy the relevant portion of the linked content into the body of your post. This keeps answers relevant even if the link goes dead. – gravity Oct 18 '16 at 17:40