py2app问题,得到错误

时间:2015-10-14 21:58:10

标签: python macos py2app

我正在尝试测试py2app的功能,用于创建独立的mac应用程序。我为我的测试代码生成了一个安装文件,名为'hello.py'。

includes

我正在尝试创建一个简单的应用程序,只需用GUI表示问候世界。这是hello.py

的代码
"""
This is a setup.py script generated by py2applet

Usage:
python setup.py py2app
"""

from setuptools import setup

APP = ['hello.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}

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

上面的脚本运行得很好,但是当我尝试使用py2app时,我遇到了一些错误。当我运行'python setup.py py2app'

import sys
from PyQt4 import QtGui
from PyQt4 import QtCore

app = QtGui.QApplication(sys.argv)

widget = QtGui.QLabel("Hello World")
widget.show()


app.exec_()

在出现这些错误之后,py2app似乎正常运行,但当然app本身不起作用。这里发生了什么?我该如何解决这个问题?

这也是终端输出的最后一行。

WARNING: ImportError in sip recipe ignored: No module named py2app-0
WARNING: ImportError in sip recipe ignored: No module named Sphinx-1
WARNING: ImportError in sip recipe ignored: No module named decorator-4
WARNING: ImportError in sip recipe ignored: No module named altgraph-0
WARNING: ImportError in sip recipe ignored: No module named matplotlib-1
WARNING: ImportError in sip recipe ignored: No module named alabaster-0
WARNING: ImportError in sip recipe ignored: No module named modulegraph-0
WARNING: ImportError in sip recipe ignored: No module named Jinja2-2
WARNING: ImportError in sip recipe ignored: No module named jedi-0
WARNING: ImportError in sip recipe ignored: No module named pickleshare-0
WARNING: ImportError in sip recipe ignored: No module named macholib-1
WARNING: ImportError in sip recipe ignored: No module named Babel-1
WARNING: ImportError in sip recipe ignored: No module named sphinx_rtd_theme-0
WARNING: ImportError in sip recipe ignored: No module named pip-7
WARNING: ImportError in sip recipe ignored: No module named wheel-0
WARNING: ImportError in sip recipe ignored: No module named python_dateutil-2

1 个答案:

答案 0 :(得分:1)

有一个小黑客可以解决这个问题,

  1. 转到您的路径/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py并打开此文件。
  2. 在第49行,将loader=loader.filename更改为loader_path=loader.filename
  3. 再次运行setup.py。