奇怪的cx_Freeze错误

时间:2017-02-12 20:36:11

标签: python cx-freeze

我正在用Python和cx_Freeze创建一个应用程序。程序本身运行良好,按预期运行,但安装脚本不能很好地工作。安装脚本在这里 -

  from cx_Freeze import setup, Executable
  import sys, cx_Freeze

  includes = ["os", "tkinter", "shutil", "time", "random", "re"]
  base = None
  if sys.platform == "win64": base = "Win64GUI"
  opts = {"include_files": ['open.bat', 'download.gif', 'mountaindew.gif', 'snipe.gif', 'Explosion.gif', 'dorito.gif', 'daoctopus.gif']}
  exe = Executable( script = "daoctopus.py",
              base = base )
  excludes = []
  packages = []
  setup(name = "DA OCTOPUS", version = "4.0",
       description = "DA OCTOPUS", author = "DA OCTOPUS Group -- ;]",
       options={"build_exe": {"excudes": excludes, "packages": packages, "include_files": opts, "includes": includes},
       executables = [exe])

但是当我跑步时:

  start python.exe setup.py build

没有创建exe,当我运行setup.py本身时,它会出错:如下所示 -

  Traceback (most recent call last):
  File "C:\Python33\Python\Workshop\Bob\Virii\DA_OCTOPUS\Essentials\setup.py", line 15, in <module>
  executables = [exe] )
  File "C:\Python33\Python\lib\site-packages\cx_Freeze\dist.py", line 361, in setup
 distutils.core.setup(**attrs)
 File "C:\Python33\Python\lib\distutils\core.py", line 109, in setup
_setup_distribution = dist = klass(attrs)
 File "C:\Python33\Python\lib\site-packages\cx_Freeze\dist.py", line 23, in __init__
 distutils.dist.Distribution.__init__(self, attrs)
 File "C:\Python33\Python\lib\distutils\dist.py", line 234, in __init__
 for (opt, val) in cmd_options.items():
 AttributeError: 'list' object has no attribute 'items'

这很奇怪,我在问如何解决它......

1 个答案:

答案 0 :(得分:0)

“include_files”参数需要一个列表。 因此,转换列表中的opts或放置

"include_files": opts["include_files"]

P.S:我希望"excudes": excludes只是你邮件中的输入错误,而不是代码......