簡體   English   中英

cx_Freeze屬性錯誤:“列表”對象沒有屬性“項目”

[英]cx_Freeze Attribute error: 'list' object has no attribute 'items'

我正在嘗試將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)]
)

您的代碼中有一些額外的括號,從而導致不必要的聲明其他列表。

您的build_exe_options聲明應為:

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

您的options參數應為:

        options = {'build_exe': build_exe_options},

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM