Py2app 模块图中出现错误

发布于 2024-09-14 12:49:29 字数 1913 浏览 13 评论 0原文

几周前,我能够使用 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)):

A few weeks ago, I was able to build Apps using py2app. I just tried it again and during the build process, I get dumped into a pdb session with the stack trace below.

It appears to be in import problem with modulegraph.py but I have the most update to date version.

This happens even with a bare minimum test file with no imports other than sys and using the setup that py2applet creates.

I've also made sure that the python I'm running py2app with is the /Library version, not the /System version.

Any Ideas?

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)):

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贱贱哒 2024-09-21 12:49:29

这似乎是此处指出的问题,应该已修复在 modulegraph 的后续 0.8 版本中。确保您的 modulegraph 版本确实是最新的;该路径有点奇怪:build/bdist.macosx-10.6-universal/egg/modulegraph。看起来您使用的是私有副本,而不是作为普通站点包安装的副本,例如 py2app (/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/站点包)。

That would appear to be a problem noted here and should have been fixed in the subsequent 0.8 release of modulegraph. Make sure your version of modulegraph is really up-to-date; the path is a little odd for it: build/bdist.macosx-10.6-universal/egg/modulegraph. Looks like you are using a private copy rather than one installed as a normal site-package like py2app (/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages).

酒废 2024-09-21 12:49:29

遇到了这个问题,但接受的答案并没有为我解决。

我发现 从 Python 脚本到带有 py2app 的便携式 Mac 应用程序,我将精简的解决方案放在这里:

编辑发生此错误的文件(对我来说,它位于名为 myenv 的虚拟环境文件夹内),位置为:
myenv/lib/python2.7/site-packages/py2app/recipes/virtualenv.py
1

myenv/lib/python2.7/site-packages/py2app/recipes/virtualenv.py

查找函数 scan_codeload_module 并在它们之前添加下划线,_scan_code_load_module。再次构建您的应用程序,它现在应该可以工作了

我知道这并不理想 - 但我现在只想有一个原型,这样就可以了。 :)

Was having this issue but the accepted answer did not solve it for me.

I found From a Python script to a portable Mac application with py2app and am putting the condensed solution here:

Edit the file where this error ocured (for me, it was inside the virtual environment folder, named myenv), at:
myenv/lib/python2.7/site-packages/py2app/recipes/virtualenv.py
1

myenv/lib/python2.7/site-packages/py2app/recipes/virtualenv.py

Look for the functions scan_code or load_module and add it an underscore before them, _scan_code and _load_module. Build again your application, it should work now

I know this is not ideal - but I just wanted to have a prototype for now so this will do. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文