py2app:modulegraph缺少scan_code [英] py2app: modulegraph missing scan_code
问题描述
由于某种原因,我无法解释或使用google,即使使用最简单的示例,py2app也会崩溃.我正在使用创建为 Projects/Test/virtenv
的python 3.4.1虚拟环境,该环境通过pip安装了py2app.
这是 $ pip list
的输出:
altgraph(0.12)macholib(1.7)模组图(0.12)点(1.5.6)py2app(0.9)设置工具(3.6)
foo.py是保存在Projects/Test/中的hello world示例文件,仅包含一行:
print('hello world')
setup.py保存为由 $ py2applet --make-setup foo.py
生成的项目/测试:
"这是由py2applet生成的setup.py脚本用法:python setup.py py2app"从setuptools导入安装程序APP = ['foo.py']DATA_FILES = []选项= {'argv_emulation':真}设置(app = APP,data_files = DATA_FILES,options = {'py2app':OPTIONS},setup_requires = ['py2app'],)
这是运行 $ python setup.py py2app
的完整输出(所有pip和python命令都是在激活虚拟环境的情况下完成的):
运行py2app创建/Users/mik/Desktop/Projects/Test/build创建/Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64创建/Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone创建/Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/app创建/Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/collect创建/Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/temp创建/Users/mik/Desktop/Projects/Test/dist创建build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/lib-dynload创建build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/Frameworks***使用配方:lxml ******使用配方:ftplib ******使用配方:******使用配方:ctypes ******使用配方:xml ******使用配方:pydoc ***追溯(最近一次通话):< module>中的文件"setup.py",第18行.setup_requires = ['py2app'],设置中的文件"/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/core.py",第148行dist.run_commands()在run_commands中的第955行,文件"/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py"self.run_command(cmd)文件/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py",第974行,在run_commandcmd_obj.run()运行中的文件"/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/build_app.py",第659行self._run()_run中的文件"/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/build_app.py",行865self.run_normal()在run_normal中的文件"/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/build_app.py",第943行self.process_recipes(mf,过滤器,flatpackages,loader_files)在process_recipes中的第824行,文件"/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/build_app.py"rval = check(self,mf)检查文件"/Users/mik/Desktop/Projects/Test/virtenv/lib/python3.4/site-packages/py2app/recipes/virtualenv.py",第80行mf.scan_code(co,m)AttributeError: 'ModuleGraph' 对象没有属性 'scan_code'
有人可以解释发生了什么事以及如何解决吗?
此处是modulegraph.py中scan_code的文档,但是在Projects/Test/virtenv/lib/python3.4/site-packages/modulegraph/modulegraph.py中找到的文件包含名为_scan_code的函数,并带有下划线.是这种破坏了py2app的更改吗?
发布此 >
从上述文件中的几个函数定义中手动删除前划线,使py2app可以正常运行.我仍然对发生的事情感到困惑
我遇到了与您相同的问题,并已解决.
我提到了此帖子
首先,搜索路径
$/yourenv/lib/python2.7/site-packages/py2app/recipes/virtualenv.py
接下来,打开此文件 virtualenv.py
,查找 scan_code
或 load_module
并将其更改为 _scan_code
或 _load_module
.
最后,尝试运行您的应用
For some reason I can't explain or google, py2app crashes on me even with the simplest examples. Im using a python 3.4.1 virtual environment created as Projects/Test/virtenv
which has py2app installed via pip.
Here is the output of $pip list
:
altgraph (0.12)
macholib (1.7)
modulegraph (0.12)
pip (1.5.6)
py2app (0.9)
setuptools (3.6)
foo.py is a hello world example file saved in Projects/Test/ and contains a single line:
print('hello world')
setup.py is saved in Projects/Test as generated by $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'],
)
Here is the full output of running $python setup.py py2app
(all pip and python commands were done with the virtual enviroment activated) :
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'
Can someone please explain whats going on and how to fix it?
EDIT: here is the documentation for scan_code in modulegraph.py, however the file found in Projects/Test/virtenv/lib/python3.4/site-packages/modulegraph/modulegraph.py contains a function called _scan_code with a leading underscore. Is this some type of change that broke py2app?
EDIT: posted this
EDIT: Manually removing leading underscores from a couple function definitions in the file mentioned allowed py2app to run without error. I'm still confused regarding what happened
I had the same problem as you and solved it now.
I referred to this post.
First, search for the path
$ /yourenv/lib/python2.7/site-packages/py2app/recipes/virtualenv.py
Next, open this file virtualenv.py
, look for scan_code
or load_module
and change it to _scan_code
or _load_module
.
Last, try to run your app
这篇关于py2app:modulegraph缺少scan_code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!