LoginSignup
4
8

More than 5 years have passed since last update.

【Python Kivy】pyinstallerでexeファイルを作成する方法

Posted at

pyinstallerでpyファイルからSPECファイルを作成します(今回pyファイルをmain.py、kvファイルをtest.kyとします)。

pyinstaller main.py

実行するとmain.specというファイルが作業ディレクトリに作成されます。
このSPECファイルを今度修正します。

ファイルを開いて、1行目にまず以下の文を挿入します。

from kivy.deps import sdl2, glew

そして次に、以下のようにTree('.'),*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)]を追記をし、nameをkvファイル名に修正します。

coll = COLLECT(exe,Tree('.'),
         a.binaries,
         a.zipfiles,
         a.datas,
         *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
         strip=False,
         upx=True,
         name='test')

そして、再度pyinstallerで今度はSPECファイルを使ってexeファイルを作成します。

pyinstaller main.spec

そうするとdistというフォルダのなかにtestというフォルダが作成され、その中にexeファイルがはいっています。

4
8
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
8