Error building executable with cx_Freeze: IndexError: tuple index out of range
Error building executable with cx_Freeze: IndexError: tuple index out of range
背景
我制作了一个程序,我试图使用 CX_Freeze 将其转换为可执行文件。 setup.py
文件与我正在使用的所有文件位于同一目录中。除了 TKinter 和 OS.
,我不使用任何额外的库
当我通过 PyCharm>运行
运行 时,该程序正常运行
版本号
- cx_Freeze 版本: - 5.0
- cx_Freeze .whl: - cx_Freeze-5.0-cp36-cp36m-win_amd64.whl
- python 版本: - 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:\Users\Jeremy\PycharmProjects\cleanup>C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\python 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:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py",
line 349, in setup
distutils.core.setup(**attrs)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\core.py",
line 148, in setup
dist.run_commands()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py",
line 955, in run_commands
self.run_command(cmd)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py",
line 974, in run_command
cmd_obj.run()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\command\build.py",
line 135, in run
self.run_command(cmd_name)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\cmd.py",
line 313, in run_command
self.distribution.run_command(command)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py",
line 974, in run_command
cmd_obj.run()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py",
line 219, in run
freezer.Freeze()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py",
line 621, in Freeze
self.finder = self._GetModuleFinder()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py",
line 333, in _GetModuleFinder
self.path, self.replacePaths)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 150, in __init__
self._AddBaseModules()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 161, in _AddBaseModules
self.IncludeModule("traceback")
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 651, in IncludeModule
namespace = namespace)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 310, in _ImportModule
deferredImports, namespace = namespace)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 403, in _InternalImportModule
parentModule, namespace)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 474, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 562, in _ScanCode
arguments.append(co.co_consts[opArg])
IndexError: tuple index out of range
我不是很熟练或不熟悉这些,所以我希望我没有遗漏任何东西。如果需要更多信息,请告诉我。
这已作为 a bug in cx_freeze
提交,Python 3.6 对代码对象进行了一些更改(最显着的是 PEP 523
),因此它可能在应用程序中引入了某些依赖于在他们身上。
跟踪 cx_freeze
上的问题,并记住在使用新发布的 Python 版本时可能会出现某些错误。
顺便说一句,由于您导入 cx_Freeze
并通过那里访问 setup
和 Executable
,因此不需要:
from cx_Freeze import setup, Executable
行。您没有使用这些名称。
背景
我制作了一个程序,我试图使用 CX_Freeze 将其转换为可执行文件。 setup.py
文件与我正在使用的所有文件位于同一目录中。除了 TKinter 和 OS.
当我通过 PyCharm>运行
运行 时,该程序正常运行版本号
- cx_Freeze 版本: - 5.0
- cx_Freeze .whl: - cx_Freeze-5.0-cp36-cp36m-win_amd64.whl
- python 版本: - 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:\Users\Jeremy\PycharmProjects\cleanup>C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\python 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:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py",
line 349, in setup
distutils.core.setup(**attrs)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\core.py",
line 148, in setup
dist.run_commands()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py",
line 955, in run_commands
self.run_command(cmd)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py",
line 974, in run_command
cmd_obj.run()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\command\build.py",
line 135, in run
self.run_command(cmd_name)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\cmd.py",
line 313, in run_command
self.distribution.run_command(command)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py",
line 974, in run_command
cmd_obj.run()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py",
line 219, in run
freezer.Freeze()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py",
line 621, in Freeze
self.finder = self._GetModuleFinder()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py",
line 333, in _GetModuleFinder
self.path, self.replacePaths)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 150, in __init__
self._AddBaseModules()
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 161, in _AddBaseModules
self.IncludeModule("traceback")
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 651, in IncludeModule
namespace = namespace)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 310, in _ImportModule
deferredImports, namespace = namespace)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 403, in _InternalImportModule
parentModule, namespace)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 474, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File
"C:\Users\Jeremy\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py",
line 562, in _ScanCode
arguments.append(co.co_consts[opArg])
IndexError: tuple index out of range
我不是很熟练或不熟悉这些,所以我希望我没有遗漏任何东西。如果需要更多信息,请告诉我。
这已作为 a bug in cx_freeze
提交,Python 3.6 对代码对象进行了一些更改(最显着的是 PEP 523
),因此它可能在应用程序中引入了某些依赖于在他们身上。
跟踪 cx_freeze
上的问题,并记住在使用新发布的 Python 版本时可能会出现某些错误。
顺便说一句,由于您导入 cx_Freeze
并通过那里访问 setup
和 Executable
,因此不需要:
from cx_Freeze import setup, Executable
行。您没有使用这些名称。