我正在尝试使用PySide和py2app构建应用程序,但我实际上在运行应用程序时遇到了问题。
我在setup.py文件上尝试了很多变种来导入PySide,但没有任何效果。我已经将setup_requires,install_requires,OPTIONS,直接导入到setup.py文件的顶部。到目前为止。
以下是我当前的setup.py文件:
from setuptools import setup
import PySide
APP = ['login.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'includes': 'PySide'}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
这是我构建setup.py文件时的样子
$ python setup.py py2app -A
running py2app
creating /Users/x/Desktop/Pycharm/desktop-app/build/bdist.macosx-10.11-x86_64/python2.7-standalone/app
creating /Users/x/Desktop/Pycharm/desktop-app/build/bdist.macosx-10.11-x86_64/python2.7-standalone/app/collect
creating /Users/x/Desktop/Pycharm/desktop-app/build/bdist.macosx-10.11-x86_64/python2.7-standalone/app/temp
creating build/bdist.macosx-10.11-x86_64/python2.7-standalone/app/lib-dynload
creating build/bdist.macosx-10.11-x86_64/python2.7-standalone/app/Frameworks
但是当我尝试运行我的应用程序时,它会挂起并崩溃并带有以下追溯
Jul 13 10:53:23 login[93037] <Notice>: Traceback (most recent call last):
Jul 13 10:53:23 login[93037] <Notice>: File "/Users/x/Desktop/Pycharm/desktop-app/dist/login.app/Contents/Resources/__boot__.py", line 376, in <module>
Jul 13 10:53:23 login[93037] <Notice>: _run()
Jul 13 10:53:23 login[93037] <Notice>: File "/Users/x/Desktop/Pycharm/desktop-app/dist/login.app/Contents/Resources/__boot__.py", line 370, in _run
Jul 13 10:53:23 login[93037] <Notice>: exec(compile(source, script, 'exec'), globals(), globals())
Jul 13 10:53:23 login[93037] <Notice>: File "/Users/x/Desktop/Pycharm/desktop-app/login.py", line 10, in <module>
Jul 13 10:53:23 login[93037] <Notice>: from utils import capture_image, manage_media, base_image_extraction, vehicle, django_communication
Jul 13 10:53:23 login[93037] <Notice>: File "/Users/x/Desktop/Pycharm/desktop-app/utils/capture_image.py", line 11, in <module>
Jul 13 10:53:23 login[93037] <Notice>: from PySide.QtGui import (QPixmap, QImage)
Jul 13 10:53:23 login[93037] <Notice>: ImportError: dlopen(/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtGui.so, 2): Library not loaded: @rpath/libpyside-python2.7.1.2.dylib
Jul 13 10:53:23 login[93037] <Notice>: Referenced from: /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtGui.so
Jul 13 10:53:23 login[93037] <Notice>: Reason: image not found
Jul 13 10:53:23 login[93037] <Notice>: 2016-07-13 10:53:23.898 login[93037:362066] login Error
我检查了路径,所提到的文件都存在,所以我没有想法。
答案 0 :(得分:0)
好吧,如果有人遇到这个问题,那是因为你必须酿造安装pyside。 pip install pyside会导致这个问题,但我不知道为什么。