cx_Freeze 'list' 对象没有属性 'items'
Posted
技术标签:
【中文标题】cx_Freeze \'list\' 对象没有属性 \'items\'【英文标题】: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")]
)
【问题讨论】:
【参考方案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
,
)
【讨论】:
以上是关于cx_Freeze 'list' 对象没有属性 'items'的主要内容,如果未能解决你的问题,请参考以下文章
CX_FREEZE 窗口 - AttributeError:“NoneType”对象没有属性写入
Windows cx_freeze 上的“AttributeError:‘NoneType’对象没有属性写入”
制作自动更新 zip cx_freeze 时出错,并且 esky 'Freezer' 对象没有属性 'createLibraryZip'
Python,AttributeError:模块'google.cloud.bigquery'在cx_Freeze构建后没有属性'Client'