cx_Freeze Python的可执行错误 - IndexError:列表索引超出范围

问题描述 投票:0回答:1

从IDLE执行时我的代码工作完全正常。我用cx_Freeze编译我的Python代码转换成可执行应用程序,现在,它不会运行。我下面将我的“setup.py”的代码。我还提供了从运行命令提示符程序的结果。

from cx_Freeze import setup, Executable
import os


os.environ['TCL_LIBRARY'] = r'C:\Program Files (x86)\Microsoft Visual 
Studio\Shared\Python36_64\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files (x86)\Microsoft Visual 
Studio\Shared\Python36_64\tcl\tk8.6'

build_exe_options = {"packages": ["numpy"]}

setup(name= 'Current-Translator',
      version = '1.0',
      description = 'Convert and plot electrical current data from data logger.',
      options = {"build_exe": build_exe_options},
      executables = [Executable('Current-Translator.py')])

命令提示符输出

Traceback (most recent call last):


File "C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
    module.run()
  File "C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
    exec(code, m.__dict__)
  File "Current-Translator.py", line 6, in <module>
  File "C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\lib\site-packages\timedelta\__init__.py", line 9, in <module>
    @public.add
  File "C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\lib\site-packages\public\__init__.py", line 65, in add
    return _add(_caller_modules()[1], objects)
IndexError: list index out of range
python python-3.x executable cx-freeze timedelta
1个回答
0
投票
  1. 尝试使用以下build_exe选项安装脚本: build_exe_options = {"packages": ["numpy", "public", "timedelta"]}
  2. 好像你正在使用cx_Freeze与Python 3.7,显然没有进一步的问题。 cx_Freeze尚不支持的Python 3.7,它有一个bug(仅适用于某些系统配置?)。一个缺陷修复存在,但尚未公布,但可以手动应用它,看到What could be the reason for fatal python error:initfsencoding:unable to load the file system codec?Cx_freeze crashing Python3.7.0。或者你可以回滚到Python 3.6,如果这是一个选择。
© www.soinside.com 2019 - 2024. All rights reserved.