几周前,我能够使用py2app构建应用程序。我刚试了一次,在构建过程中,我被转入pdb会话,下面是堆栈跟踪。
似乎是在modulegraph.py的导入问题,但我对日期版本的更新最多。
即使只有最小的测试文件,除了sys之外没有导入并使用py2applet创建的设置,这种情况也会发生。
我还确保我运行py2app的python是/ Library版本,而不是/ System版本。
任何想法?
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py2app-0.4.3-py2.6.egg/py2app/build_app.py", line 589, in _run
self.run_normal()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py2app-0.4.3-py2.6.egg/py2app/build_app.py", line 641, in run_normal
mf = self.get_modulefinder()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py2app-0.4.3-py2.6.egg/py2app/build_app.py", line 549, in get_modulefinder
debug=debug,
File "build/bdist.macosx-10.6-universal/egg/modulegraph/find_modules.py", line 255, in find_modules
find_needed_modules(mf, scripts, includes, packages)
File "build/bdist.macosx-10.6-universal/egg/modulegraph/find_modules.py", line 180, in find_needed_modules
mf.import_hook(mod[:-2], None, ['*'])
File "build/bdist.macosx-10.6-universal/egg/modulegraph/modulegraph.py", line 404, in import_hook
modules.update(self.ensure_fromlist(m, fromlist))
File "build/bdist.macosx-10.6-universal/egg/modulegraph/modulegraph.py", line 472, in ensure_fromlist
fromlist.update(self.find_all_submodules(m))
File "build/bdist.macosx-10.6-universal/egg/modulegraph/modulegraph.py", line 496, in find_all_submodules
for (path, mode, typ) in ifilter(None, imap(moduleInfoForPath, names)):
NameError: global name 'ifilter' is not defined
> /Users/justin/Desktop/test/build/bdist.macosx-10.6-universal/egg/modulegraph/modulegraph.py(496)find_all_submodules()
-> for (path, mode, typ) in ifilter(None, imap(moduleInfoForPath, names)):
答案 0 :(得分:2)
这似乎是一个注意到here的问题,应该在modulegraph的后续0.8版本中修复。确保您的modulegraph
版本真的是最新的;路径有点奇怪:build/bdist.macosx-10.6-universal/egg/modulegraph
。看起来您使用的是私人副本,而不是像py2app
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
这样的普通网站包安装的私有副本。
答案 1 :(得分:0)
遇到这个问题,但接受的答案并没有为我解决。
我找到了From a Python script to a portable Mac application with py2app,并将精简解决方案放在此处:
编辑此错误发生的文件(对我来说,它位于虚拟环境文件夹中,名为myenv),位于: myenv / lib目录/ python2.7 /站点包/ py2app /食谱/ virtualenv.py 1
myenv/lib/python2.7/site-packages/py2app/recipes/virtualenv.py
查找函数
scan_code
或load_module
并在它们之前添加下划线,_scan_code
和_load_module
。再次构建您的应用程序,它现在应该可以正常工作
我知道这不太理想 - 但我现在想要一个原型,所以这样做。 :)