本文介绍了py2app问题,出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to test out the functionality of py2app, for creating standalone mac applications. I generated a setup file for my test code, called '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'],
)

我正在尝试制作一个简单的应用程序,该应用程序仅通过GUI来向您问好世界.这是hello.py

And I'm trying to make a simple app that just says hello world with a GUI. Here is the code for hello.py

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时,出现了一些错误.当我运行'python setup.py py2app'

The script above runs just fine, but when I try to use py2app, I get some errors. When I run 'python setup.py py2app'

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

出现这些错误后,py2app似乎可以正常运行,但是该应用程序本身无法正常工作.这里发生了什么?我该如何解决?

After these errors, it py2app seems to be running as it normally should, but of course the app itself does not work. What is going on here? How do I fix this?

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

Here is the final line of the Terminal output as well.

Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/Users/Apollo/miniconda/lib/python2.7/distutils/core.py", line 151, in          setup
dist.run_commands()
File "/Users/Apollo/miniconda/lib/python2.7/distutils/dist.py", line 953, in   run_commands
self.run_command(cmd)
File "/Users/Apollo/miniconda/lib/python2.7/distutils/dist.py", line 972, in   run_command
cmd_obj.run()
File "/Users/Apollo/miniconda/lib/python2.7/site- packages/py2app/build_app.py", line 659, in run
self._run()
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/py2app/build_app.py", line 865, in _run
self.run_normal()
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/py2app/build_app.py", line 959, in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/py2app/build_app.py", line 1214, in create_binaries
platfiles = mm.run()
File "/Users/Apollo/miniconda/lib/python2.7/site- packages/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'

推荐答案

有一个小技巧可以解决此问题,

There is a small hack that will work for this problem,

  1. 转到路径/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py并打开此文件.
  2. 在第49行上,将loader=loader.filename更改为loader_path=loader.filename
  1. Go to your path /Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py and open this file.
  2. On line 49, change loader=loader.filename to loader_path=loader.filename

再次运行setup.py.

Run the setup.py again.

这篇关于py2app问题,出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 18:36