简体   繁体   中英

(PyQt4, py2app and pyinstaller crash when moving .app to another machine

So I am trying to build a Mac osx app from python using PyQt4 and either py2app or pyinstaller. Both these scripts build apps that work fine on my build machine ( running mavericks 10.9.5 ) but when I try to use it on another machine they both crash with an EXC_BAD_INSTRUCTION and then list QT libraries.

I think that maybe my apps are not including the Qt libraries in the build. My setup file for py2app looks like this

This is a setup.py script generated by py2applet

Usage:

    python setup.py py2app

from setuptools import setup

APP = ['FudgeTestpy.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'includes': ['sip', 'PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui'], 

'excludes': ['PyQt4.QtDesigner', 'PyQt4.QtNetwork', 'PyQt4.QtOpenGL', 'PyQt4.QtScript', 
'PyQt4.QtSql', 'PyQt4.QtTest', 'PyQt4.QtWebKit', 'PyQt4.QtXml', 'PyQt4.phonon']}

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

I actually managed to fix this issue by installing MacPorts and installing python27. I couldn't build standalone application bundles with the system python in OS X using py2app. So in order to build standalone PyQt apps, I setup Python, PyQt, etc., under MacPorts.

I solved this problem. are you using the python's brew environment? if so, try to build it on the default python environment, not the brew.

I had the same issue - my setup was python3 and pyqt4, both installed via brew. First I completely removed brew:

cd `brew --prefix`
rm -rf Cellar
brew prune
rm -rf Library .git .gitignore bin/brew README.md share/man/man1/brew
rm -rf ~/Library/Caches/Homebrew

(These steps are taken from here ) After installing macports, the pyqt4 lib is installed by

sudo port install py34-pyqt4

This will automatically install python3 and all required dependencies. Note that macports installs python (and all other stuff) to /opt/local/bin. There is also a package in macports for py2app, so there is no need to use pip:

sudo port install py34-py2app

Now there is no problem running a packaged app on other systems. I am not 100% sure what the underlying problem really is, but in my case I suspect that sip via brew ran some optimizations for my systems that caused incompatibilities...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM