py2app problems, getting errors

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

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'], ) 

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_() 

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 

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' 

回答1:

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

  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

Run the setup.py again.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!