【问题标题】:cx_Freeze 'list' object has no attribute 'items'cx_Freeze 'list' 对象没有属性 'items'
【发布时间】:2018-04-20 22:59:48
【问题描述】:

我正在尝试将 pygame 文件转换为 .exe,并且我正在使用 cx_Freeze 来完成它

但是,当我在控制台中输入 py setup.py build 时,它会响应:

PS C:\Python34> py setup.py build
Traceback (most recent call last):

  File "setup.py", line 22, in <module>
    executables = [cx_Freeze.Executable("CattwalkV3C.py")]
  File "C:\Python34\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
    distutils.core.setup(**attrs)
  File "C:\Python34\lib\distutils\core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "C:\Python34\lib\site-packages\cx_Freeze\dist.py", line 24, in __init__
    distutils.dist.Distribution.__init__(self, attrs)
  File "C:\Python34\lib\distutils\dist.py", line 236, in __init__
    for (opt, val) in cmd_options.items():
AttributeError: 'list' object has no attribute 'items' 

我已经看到了有关此问题的其他几个问题,但他们都只是说某些项目被过度封装。这是我的代码:

import cx_Freeze
from cx_Freeze import *

files = ["BLUE CALLISTO.png", "RED CALLISTO.png", "BLUE LUNA.png",
"RED LUNA.png", "BLUE DEIMOS.png", "RED DEIMOS.png"
"BLUE GANYMEDE.png", "RED GANYMEDE.png", "BLUE IO.png",
"RED IO.png", "BLUE EUROPA.png", "RED EUROPA.png",
"BLUE TITAN.png", "RED TITAN.png", "RED SOL.png",
"BLUE SOL.png", "CattwalkBoard.png", "STYX.png"
"blue turn.png", "red turn.png", "LongLine.png",
"ShortLine.png", "PlaceHolder.png"]

includeThese = ["pygame", "pickle", "os", "random", "time", "math", 
"socket"]

cx_Freeze.setup(
    name = "CattwalkV3C",
    options = {"build_exe":{"packages": includeThese},
                                    "include_files": files},

    executables = [cx_Freeze.Executable("CattwalkV3C.py")]
)

【问题讨论】:

    标签: python pygame executable cx-freeze file-type


    【解决方案1】:

    我认为您的格式有点混乱,请尝试使用此格式:

    import cx_Freeze
    from cx_Freeze import *
    
    files = ["BLUE CALLISTO.png", "RED CALLISTO.png", "BLUE LUNA.png",
    "RED LUNA.png", "BLUE DEIMOS.png", "RED DEIMOS.png"
    "BLUE GANYMEDE.png", "RED GANYMEDE.png", "BLUE IO.png",
    "RED IO.png", "BLUE EUROPA.png", "RED EUROPA.png",
    "BLUE TITAN.png", "RED TITAN.png", "RED SOL.png",
    "BLUE SOL.png", "CattwalkBoard.png", "STYX.png"
    "blue turn.png", "red turn.png", "LongLine.png",
    "ShortLine.png", "PlaceHolder.png"]
    executables = [cx_Freeze.Executable("CattwalkV3C.py")]
    includeThese = ["pygame", "pickle", "os", "random", "time", "math", 
    "socket"]
    
    cx_Freeze.setup(
        name = "CattwalkV3C",
        options = {"build_exe":{"packages": includeThese,
                                "include_files": includeThese 
                                },
                   })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-12
      • 1970-01-01
      • 1970-01-01
      • 2015-11-14
      • 2013-09-22
      • 2019-07-22
      • 2015-09-30
      • 2020-09-22
      相关资源
      最近更新 更多