3

I have some troubles with py2app; for some reason I have always the same error for all scripts that I developed. At the moment I am using last MacPorts version and after two days of testing I cannot figure out what is wrong.

One of the setup.py file for py2app is:

from setuptools import setup

APP = ['main.py']
OPTIONS = {'argv_emulation': True, 'includes': ['sip', 'PyQt4._qt', '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,
      options={'py2app': OPTIONS},
      setup_requires=['py2app'],
)

And this is the log:

python setup.py py2app
running py2app
creating /Users/opensw/SkyDrive/SISSA/Kymograph/build/bdist.macosx-10.6-intel/python2.7-standalone/app
creating /Users/opensw/SkyDrive/SISSA/Kymograph/build/bdist.macosx-10.6-intel/python2.7-standalone/app/collect
creating /Users/opensw/SkyDrive/SISSA/Kymograph/build/bdist.macosx-10.6-intel/python2.7-standalone/app/temp
creating build/bdist.macosx-10.6-intel/python2.7-standalone/app/lib-dynload
creating build/bdist.macosx-10.6-intel/python2.7-standalone/app/Frameworks
*** using recipe: virtualenv ***
WARNING: ImportError in sip recipe ignored: No module named matplotlib-1
WARNING: ImportError in sip recipe ignored: No module named scipy-0
*** using recipe: sip ***
*** using recipe: matplotlib ***
*** using recipe: scipy ***
Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    setup_requires=['py2app'],
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Users/opensw/SkyDrive/SISSA/Kymograph/py2app-0.7.3-py2.7.egg/py2app/build_app.py", line 553, in run
    self._run()
  File "/Users/opensw/SkyDrive/SISSA/Kymograph/py2app-0.7.3-py2.7.egg/py2app/build_app.py", line 741, in _run
    self.run_normal()
  File "/Users/opensw/SkyDrive/SISSA/Kymograph/py2app-0.7.3-py2.7.egg/py2app/build_app.py", line 816, in run_normal
    self.process_recipes(mf, filters, flatpackages, loader_files)
  File "/Users/opensw/SkyDrive/SISSA/Kymograph/py2app-0.7.3-py2.7.egg/py2app/build_app.py", line 710, in process_recipes
    find_needed_modules(mf, packages=rval['packages'])
  File "build/bdist.macosx-10.6-intel/egg/modulegraph/find_modules.py", line 199, in find_needed_modules
TypeError: 'NoneType' object has no attribute '__getitem__'

Thanks for any help.

4

1 回答 1

10

问题是一些错误的输入已传递给算法,该算法试图检测依赖关系以便将它们打包到您的应用程序中 - 我遇到问题的地方之一是在包 README 中使用 github 风格的降价。 md 文件。

这是调试 setup.py 问题的一般指南,或者实际上是一般的 python 问题。

  1. 以交互模式再次运行它,即python -i setup.py py2app. 退出setup.py后,您会发现自己处于 python 提示符中。

  2. 运行from pdb import pm; pm()。您现在应该发现自己处于调试提示符下。

  3. 键入up并按 Enter - 您现在是堆栈中更高的帧 - 您可以键入list以查看当前帧在源代码中的位置,并args查看传递给当前帧的参数(通常是函数或方法)。您还可以运行 python 命令来检查当前状态,并运行pp var以漂亮地打印该变量。

  4. 重复上述步骤几次后,您会发现错误出现的位置 - 如果我遇到的是 README 文件,我发现了一个名为的变量lineno,它给出了导致错误的 README 文件的行。如果您的问题是模块导入,它可能会有所不同,但我的直觉是,您会发现自己packages在堆栈跟踪中看到的参数上循环,当前列表项将是您问题的关键。

于 2013-05-08T15:53:24.350 回答