cx_Freeze属性错误:' list'对象没有属性' items'

时间:2017-09-07 01:43:51

标签: python cmd exe cx-freeze attributeerror

我正在尝试将python文件转换为可执行文件,但是当我运行

python setup.py build

在我的命令行中,我收到错误说

Attribute Error:  'list' object has no attribute 'items'  

我的设置文件或我的代码的主文件中存在问题吗?

import sys
from cx_Freeze import setup, Executable

includefiles = ['Arcade Funk.mp3', 'game over.wav', 'FrogTown.wav','pixel ufo.png','introBackground.png','pixel playButton.png','pixel instructionButton.png','pixel playButtonHighlighted.png','pixel instructionButtonHighlighted.png','instructionPage.png','crashBackground.png','space background long.png','pixel earth.png','pixel asteroid.png', 'pixel icon.png','Montserrat-ExtraBold.otf','Montserrat-Bold.otf','arial.ttf']
includes = []
excludes = ['Tkinter']
packages = ['pygame']
build_exe_options = {'includes':[includes],'packages':[packages], 'excludes':[excludes], 'include_files':[includefiles]}

base = None
if sys.platform == 'win64':
    base = 'Win64GUI'
elif sys.platform == 'win32':
    base = 'Win32GUI'

setup(  name = 'Earth Invaders',
        version = '0.1',
        description = 'Slider Game: Space',
        options = {'build_exe': [build_exe_options]},
        executables = [Executable('EarthInvaders.py', base=base)]
)

1 个答案:

答案 0 :(得分:0)

您的代码中有一些额外的括号,导致不必要的其他列表声明。

您的build_exe_options声明应为:

build_exe_options = {'includes':includes, 'packages':packages, 'excludes':excludes, 'include_files':includefiles}

您的选项参数应为:

        options = {'build_exe': build_exe_options},