Pyinstaller打包小遊戲

2021-10-08 21:15:15 字數 3465 閱讀 3351

小遊戲中包含多個資料夾,以及、json檔案等,對這種package進行打包,

檔案目錄如下:

目錄中包含多層級。

開始打包:

pyinstaller -f -w main1.py
# -*- mode: python ; coding: utf-8 -*-

block_cipher =

none

setup_dir =

'd:\\pyfile\\pythonsupermario-master\\pythonsupermario-master'

a = analysis(

['main1.py'

,#所有能用到的py檔案

'd:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\constants.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\main.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\setup.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\tools.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\components\\box.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\components\\brick.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\components\\coin.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\components\\enemy.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\components\\info.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\components\\player.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\components\\powerup.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\components\\stuff.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\states\\level.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\states\\load_screen.py'

,'d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master\\source\\states\\main_menu.py'],

pathex=

['d:\\pyfile\\pythonsupermario-master\\pythonsupermario-master'],

binaries=

, datas=

[(setup_dir +

'\\resources'

,'\\resources'),

(setup_dir +

'\\resources\\demo'

,'\\resources\\demo'),

(setup_dir +

'\\resources\\graphics'

,'\\resources\\graphics'),

(setup_dir +

'\\source\\data'

,'\\source\\data'),

(setup_dir +

'\\source\\data\\maps'

,'\\source\\data\\maps'),

(setup_dir +

'\\source\\data\\player'

,'\\source\\data\\player')]

,# 其他檔案所在目錄,包含多層時,需要建立多層目錄

hiddenimports=

, hookspath=

, runtime_hooks=

, excludes=

, win_no_prefer_redirects=

false

, win_private_assemblies=

false

, cipher=block_cipher,

noarchive=

false

)pyz = pyz(a.pure, a.zipped_data,

cipher=block_cipher)

exe = exe(pyz,

a.scripts,

a.binaries,

a.zipfiles,

a.datas,

, name=

'main1'

, debug=

false

, bootloader_ignore_signals=

false

, strip=

false

, upx=

true

, upx_exclude=

, runtime_tmpdir=

none

, console=

true

)

所有檔案準備好之後,再次執行

pyinstaller main1.spec
最後生成的exe檔案在dist檔案裡面。

pyinstaller打包程式

python打包成exe檔案時,用的是pyinstaller 第一步安裝pyinstaller pip install pyinstaller第二步 pyinstaller f w i ico py其中 ico 是logo,py是你要打包的py檔案 我在打包時出現了struct.error unpa...

pyinstaller打包使用

pyinstaller manage.py 如果直接打包報錯,使用如下命令可以直接生成配置檔案 pyi makespec d manage.py生成的配置檔案格式如下 mode python coding utf 8 block cipher none a analysis impala etl.p...

pyinstaller 打包總結

pyinstaller 打包過程總結 安裝 pyinstaller 打包工具 pip3 install pyinstallerpyinstaller 打包命令不熟悉的小夥伴可點選這裡檢視喲 備註 以下涉及到的檔案名字main.py,請替換成自己的檔名 執行打包命令生成單獨的 exe 程式 pyins...