gpt4 book ai didi

python - py2app: modulegraph 缺少 scan_code

转载 作者:太空狗 更新时间:2023-10-29 17:45:25 26 4
gpt4 key购买 nike

出于某种原因,我无法解释或谷歌,即使使用最简单的示例,py2app 也会让我崩溃。我使用的是创建为 Projects/Test/virtenv 的 python 3.4.1 虚拟环境,它通过 pip 安装了 py2app。

这是 $pip list 的输出:

altgraph (0.12)
macholib (1.7)
modulegraph (0.12)
pip (1.5.6)
py2app (0.9)
setuptools (3.6)

foo.py 是保存在 Projects/Test/中的 hello world 示例文件,包含一行:

print('hello world')

setup.py 保存在 Projects/Test 中,由 $py2applet --make-setup foo.py 生成:

"""
This is a setup.py script generated by py2applet

Usage:
python setup.py py2app
"""

from setuptools import setup

APP = ['foo.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}

setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)

这是运行 $python setup.py py2app 的完整输出(所有 pip 和 python 命令都是在激活虚拟环境的情况下完成的):

running py2app
creating /Users/mik/Desktop/Projects/Test/build
creating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64
creating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone
creating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/app
creating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/collect
creating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/temp
creating /Users/mik/Desktop/Projects/Test/dist
creating build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/lib-dynload
creating build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/Frameworks
*** using recipe: lxml ***
*** using recipe: ftplib ***
*** using recipe: sip ***
*** using recipe: ctypes ***
*** using recipe: xml ***
*** using recipe: pydoc ***
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/build_app.py", line 659, in run
self._run()
File "/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/build_app.py", line 865, in _run
self.run_normal()
File "/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/build_app.py", line 943, in run_normal
self.process_recipes(mf, filters, flatpackages, loader_files)
File "/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/build_app.py", line 824, in process_recipes
rval = check(self, mf)
File "/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/recipes/virtualenv.py", line 80, in check
mf.scan_code(co, m)
AttributeError: 'ModuleGraph' object has no attribute 'scan_code'

谁能解释一下这是怎么回事以及如何解决它?

编辑:here是 modulegraph.py 中 scan_code 的文档,但是在 Projects/Test/virtenv/lib/python3.4/site-packages/modulegraph/modulegraph.py 中找到的文件包含一个名为 _scan_code 的函数,带有前导下划线。这是破坏 py2app 的某种类型的更改吗?

编辑:发布this

编辑:从提到的文件中的几个函数定义中手动删除前导下划线允许 py2app 运行而不会出错。我仍然对发生的事情感到困惑

最佳答案

我遇到了和你一样的问题,现在解决了。

我提到了这个post .

首先,搜索路径

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

接下来,打开这个文件virtualenv.py,寻找scan_codeload_module并将其更改为_scan_code_load_module

最后,尝试运行您的应用

关于python - py2app: modulegraph 缺少 scan_code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25394320/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com