gpt4 book ai didi

python - AttributeError : module 'dis' has no attribute '_unpack_opargs' While Building Python 3. 6 可执行使用 CX_FREEZE

转载 作者:行者123 更新时间:2023-11-28 21:06:56 26 4
gpt4 key购买 nike

我一直在尝试将我的 Python 3.6 程序转换为 .EXE。当我使用 cx_Freeze 构建时。它会产生以下错误。 (见下面的日志)

我之前使用的是 Kivy 模块,但在构建反复失败后,我仍然尝试使用简单的 Hello World 程序,但它失败了。

我的安装文件包含from cx_Freeze import setup, Executable 导入语句,

当我通过 python setup.py build 构建时,它会生成此日志。

F:\Python\test>python setup.py build
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 7, in
executables = [Executable('hello.py')])
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\dist.py", line 349, in setup
distutils.core.setup(**attrs)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\core.py", li
ne 148, in setup
dist.run_commands()
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\dist.py", li
ne 955, in run_commands
self.run_command(cmd)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\dist.py", li
ne 974, in run_command
cmd_obj.run()
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\command\buil
d.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\cmd.py", lin
e 313, in run_command
self.distribution.run_command(command)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\dist.py", li
ne 974, in run_command
cmd_obj.run()
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\dist.py", line 219, in run
freezer.Freeze()
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\freezer.py", line 621, in Freeze
self.finder = self._GetModuleFinder()
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\freezer.py", line 333, in _GetModuleFinder
self.path, self.replacePaths)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 150, in <strong>init</strong>
self._AddBaseModules()
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 161, in _AddBaseModules
self.IncludeModule("traceback")
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 645, in IncludeModule
namespace = namespace)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 310, in _ImportModule
deferredImports, namespace = namespace)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 403, in _InternalImportModule
parentModule, namespace)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 474, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 544, in _ScanCode
method = dis._unpack_opargs if sys.version_info[:2] >= (3, 5) \
AttributeError: module 'dis' has no attribute '_unpack_opargs'<p></p>

<p>F:\Python\test></p>

感谢您的帮助。

最佳答案

1. 打开文件 C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freeze\finder.py:

2.更改(在第 544 行):

   method = dis._unpack_opargs if sys.version_info[:2] >= (3, 5) \
else self._UnpackOpArgs

到:

   method = self._UnpackOpArgs

3. 保存文件并尝试再次构建 ;)

关于python - AttributeError : module 'dis' has no attribute '_unpack_opargs' While Building Python 3. 6 可执行使用 CX_FREEZE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42098453/

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