我试图将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")]
)
答案 0 :(得分:0)
我相信你的格式有些混乱,请尝试使用这个:
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
},
})