python - 什么导致IndexError:py2exe中的元组索引超出范围
问题描述
我刚刚安装了 Python 3.8.5 和 py2exe 0.9.2.2。我有一个 setup.py 可以在 Python 2.7 上与 py2exe 0.6.9 一起使用。当我使用新版本运行
setup.py py2exe
(实际命令行是
py setupexe.py py2exe
)时,我得到:
Traceback (most recent call last):
File "setupexe.py", line 4, in <module>
setup(name='md2html',
File "C:\Program Files\Python38\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files\Python38\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files\Python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\Gary\AppData\Roaming\Python\Python38\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
File "C:\Users\Gary\AppData\Roaming\Python\Python38\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
File "C:\Users\Gary\AppData\Roaming\Python\Python38\site-packages\py2exe\runtime.py", line 160, in analyze
self.mf.import_hook(modname)
File "C:\Users\Gary\AppData\Roaming\Python\Python38\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Users\Gary\AppData\Roaming\Python\Python38\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Users\Gary\AppData\Roaming\Python\Python38\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Users\Gary\AppData\Roaming\Python\Python38\site-packages\py2exe\mf3.py", line 388, in _scan_code
for what, args in self._scan_opcodes(code):
File "C:\Users\Gary\AppData\Roaming\Python\Python38\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes
yield "store", (names[oparg],)
IndexError: tuple index out of range
setup.py:
from distutils.core import setup
import py2exe
from md2html import __VERSION__
setup(name='md2html',
version=__VERSION__,
author='xxxxx',
author_email='xxxxx',
description='Convert Markdown to HTML',
requires=['markdown(>=2.6.6)'],
console=['md2html.py'],
options={"py2exe":{
"excludes": [
'pyreadline', 'difflib', 'doctest', 'optparse', 'pickle', 'calendar', 'email', 'ftplib', 'httplib', 'rfc822', 'socket', 'select', 'ssl', '_ssl'] # Exclude standard library
}}
)
正如我所说,这以前有效。我的下一步是在 pdb 中运行它,但在我跳入不熟悉的代码之前,我想我会问。在 Windows 10 上运行。谢谢。更新:这个问题产生了类似的错误。答案是 py2exe 不适用于 Python 3.4 之后的版本。令人失望!它建议pyinstaller,我将对其进行调查。我真的希望有办法让 py2exe 工作。
解决方案
推荐阅读
- django - Django 1.11 dict 作为 .create 的输入?
- python - Python3变量传递问题
- c# - 你怎么知道是自动化测试还是使用手动?
- cmd - CMD 不会执行基本 CD \
- flutter - 流构建器是否一次又一次地构建我的小部件而流没有任何变化?
- python-3.x - 如何在文本搜索后重新出现 Sublime Text 中的较低输出查看面板?
- c - 带有标头的 C 循环依赖
- python - 禁止来自 Python/unittest 的所有输出
- excel - 如何在代码中调用用户定义函数?
- angular - 如何覆盖 ngx-formly 上的主包装器