从上述文件中的几个函数定义中手动删除前划线,使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 py2appletUsage: python setup.py py2app"""from setuptools import setupAPP = ['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 py2appcreating /Users/mik/Desktop/Projects/Test/buildcreating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64creating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalonecreating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/appcreating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/collectcreating /Users/mik/Desktop/Projects/Test/build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/tempcreating /Users/mik/Desktop/Projects/Test/distcreating build/bdist.macosx-10.8-x86_64/python3.4-standalone/app/lib-dynloadcreating 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 thisEDIT: 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.pyNext, 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 06:03