python - 遵循教程后 Python 'py2exe' 不起作用
问题描述
我正在尝试使用“Hello World”来遵循 py2exe 教程,但遇到了错误。这是我的步骤。创建hello.py
如下:
print ('Hello World!')
确保它有效:
D:\Users\test>python hello.py
Hello World!
按照说明创建setup.py
:
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
运行dos命令:
D:\Users\test>python setup.py install
running install
running install_egg_info
Removing C:\Python364\Lib\site-packages\UNKNOWN-0.0.0-py3.6.egg-info
Writing C:\Python364\Lib\site-packages\UNKNOWN-0.0.0-py3.6.egg-info
D:\Users\test>
然后运行另一个 DOS 命令:
D:\Users\test>python setup.py py2exe
running py2exe
Traceback (most recent call last):
File "setup.py", line 4, in <module>
setup(console=['hello.py'])
File "C:\Python364\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python364\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python364\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python364\lib\site-packages\py2exe\distutils_buildexe.py", line 188,
in run
self._run()
File "C:\Python364\lib\site-packages\py2exe\distutils_buildexe.py", line 267,
in _run
builder.analyze()
File "C:\Python364\lib\site-packages\py2exe\runtime.py", line 160, in analyze
self.mf.import_hook(modname)
File "C:\Python364\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python364\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python364\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_lo
ad
self._scan_code(module.__code__, module)
File "C:\Python364\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code
for what, args in self._scan_opcodes(code):
File "C:\Python364\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcode
s
yield "store", (names[oparg],)
IndexError: tuple index out of range
D:\Users\test>
有没有人遇到过同样的情况?
来自Python - IndexError: tuple index out of range when using py2exe,我在 Python 3.6 程序中使用了https://github.com/albertosottile/py2exe上的 py2exe 的分支,@Rasjid Wilcox 发表的评论,https ://github.com/albertosottile/py2exe适用于 Python 3.6。它也适用于 32 位。
解决方案
推荐阅读
- ruby-on-rails - 如何在 PhusionPassenger.on_event() 分叉后插入代码
- ruby-on-rails - 使用 Bootstrap 组件扩展 Trix
- java - 将两个表视图绑定在一起,但由于内容行高不同导致索引不匹配
- git - Git 强制提交和推送,当得到“没有提交”
- android - 从 Google Play 获取付费应用的购买令牌
- swift - “不支持可变枚举案例” swift 5 错误
- r - 有没有比 fread() 更快的方法来读取大数据?
- javascript - 根据数字输入部署多个 div
- spring - Spring boot OneToOne 关系问题
- spring-boot - 尝试向外部端点发送后请求时过早关闭连接