使用 cx_Freeze 构建可执行文件时出错:索引错误:元组索引超出范围



Background

我已经制作了一个程序,我正在尝试使用CX_Freeze将其转换为可执行文件。setup.py文件与我正在使用的所有文件放在同一个目录中。除了 TKinter 和 OS 之外,我不使用任何额外的库。

当我通过PyCharm>Run运行时,该程序通常运行良好


版本号

  • cx_Freeze版本:- 5.0
  • cx_Freeze .whl:- cx_Freeze-5.0-CP36-CP36M-win_amd64.whl
  • 蟒蛇版本:- 3.6.0b4
  • Pycharm 版本:- 2016.3.1

这是我setup.py文件

import cx_Freeze
import sys
from cx_Freeze import setup, Executable

base = None
if sys.platform == 'win32':
base = "Win32GUI"
cx_Freeze.setup(
name = "FileOrganizer-Client",
options = {"build_exe": {"packages":["tkinter","os"],"include_files":["icon2.ico"]}},
version = "0.01",
description = "File Organizer",
executables = [cx_Freeze.Executable("alpha_GUI.py", base=base, icon="icon2.ico")]
)

这是我在目录中运行"python setup.py build"时遇到的错误

C:UsersJeremyPycharmProjectscleanup>C:UsersJeremyAppDataLocalProgramsPythonPython36python setup.py build running build running build_exe
Traceback (most recent call last):   File "setup.py", line 18, in
<module>
executables = [cx_Freeze.Executable("alpha_GUI.py", base=base, icon="icon2.ico")]
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezedist.py",
line 349, in setup
distutils.core.setup(**attrs)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libdistutilscore.py",
line 148, in setup
dist.run_commands()
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libdistutilsdist.py",
line 955, in run_commands
self.run_command(cmd)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libdistutilsdist.py",
line 974, in run_command
cmd_obj.run()
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libdistutilscommandbuild.py",
line 135, in run
self.run_command(cmd_name)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libdistutilscmd.py",
line 313, in run_command
self.distribution.run_command(command)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libdistutilsdist.py",
line 974, in run_command
cmd_obj.run()
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezedist.py",
line 219, in run
freezer.Freeze()
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefreezer.py",
line 621, in Freeze
self.finder = self._GetModuleFinder()
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefreezer.py",
line 333, in _GetModuleFinder
self.path, self.replacePaths)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefinder.py",
line 150, in __init__
self._AddBaseModules()
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefinder.py",
line 161, in _AddBaseModules
self.IncludeModule("traceback")
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefinder.py",
line 651, in IncludeModule
namespace = namespace)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefinder.py",
line 310, in _ImportModule
deferredImports, namespace = namespace)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefinder.py",
line 403, in _InternalImportModule
parentModule, namespace)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefinder.py",
line 474, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File
"C:UsersJeremyAppDataLocalProgramsPythonPython36libsite-packagescx_Freezefinder.py",
line 562, in _ScanCode
arguments.append(co.co_consts[opArg])
IndexError: tuple index out of range

我对此不是很熟练或熟悉,所以我希望我没有遗漏任何东西。如果需要更多信息,请告诉我。

> 这在cx_freeze中作为错误提交,Python 3.6 对代码对象进行了一些更改(最明显的是PEP 523),因此它可能在依赖它们的应用程序中引入了某些错误。

cx_freeze上跟踪问题,并记住在使用新发布的 Python 版本时可能会弹出某些错误。


顺便说一句,由于您导入cx_Freeze并通过那里访问setupExecutable,因此不需要:

from cx_Freeze import setup, Executable

线。您没有使用这些名称。

最新更新