简体   繁体   中英

Strange cx_Freeze Error

I am creating a application with Python and cx_Freeze. The program itself works great, doing what it is supposed to, but the setup script won't work very well. The setup script is here--

  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])

But when I run:

  start python.exe setup.py build

The exe isn't created, and when I run the setup.py itself, It makes a error: shown below--

  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'

It's very strange, and I'm asking how to fix it...

The "include_files" parameter expects a list. So transform your opts in a list or put

"include_files": opts["include_files"]

PS : I hope "excudes": excludes is just a typing mistake in your message and not in the code ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM