2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Python×Flet】exe化したデスクトップアプリ配布方法(Pyinstallerなし)

Last updated at Posted at 2025-09-23

はじめに

この記事ではpythonのGUIライブラリ、Fletを使用し、デスクトップアプリをexeファイルにして、配布する方法を記述しています。pyinstallerなしで実施可能です。
Windowsで動作するデスクトップアプリをexeファイルにしますが、他のbuildにも応用できると思います。

著者環境

  • Windows11
  • Python3.10.11

Fletのインストール方法

pip環境下で下記コマンドを実行してください。本記事では0.28.3を用います。

pip install flet

インストール後、fletコマンドがpowershellで使用可能か確認してください。
fletと打つだけでokです。

PS C:\Users\scarl> flet
usage: flet [-h] [--version] {create,run,build,pack,publish,doctor} ...

positional arguments:
  {create,run,build,pack,publish,doctor}
    create              Create a new Flet app from a template.
    run                 Run a Flet app in hot-reload mode.
    build               Build an executable app or install bundle.
    pack                Package Flet app to a desktop standalone bundle.
    publish             Publish Flet app as a standalone web app.
    doctor              `flet doctor` command to provide information about the system and environment setup.

options:
  -h, --help            show this help message and exit
  --version, -V         show program's version number and exit

もしfletコマンドが機能しない場合は‥

下記コマンドを実行してください。

pip uninstall flet

その後、管理者権限からpowershellを開き、再度インストールしてください。

Fletアプリの作成

下記コマンドを実行すると、ディレクトリにFletアプリのひな型を作成することができます。

flet create

image.png

アプリのお試し起動

下記コマンドを実行することにより、Fletアプリを起動することができます。

flet run

ホットリロードに対応しているので、コードの変更をアプリケーションにすぐ反映することができます。
この記事ではアプリの作成をメインにしていないので、アプリはテンプレートのまま、exe化します。

Exe化に向けた環境構築

Visual Studio(Windowsビルドツール)とFlutter SDKを別途導入する必要があります。

Windowsビルドツールの導入

世の中にたくさん記事があるので、ここでは省略します。
一応参考までに記事を張っておきます。
https://qiita.com/matskeng/items/43988856501ca94526e4

Flutter SDKの導入

下記リンクより、ダウンロード可能です。
https://docs.flutter.dev/get-started/install/windows/desktop

VSCodeを用いたinstall方法もあるみたいですが、私はzipファイルの方を選択しました。
image.png

zipファイルをダウンロード後、展開します。
その後、binフォルダのpathを環境変数のpathに登録します。
image.png

↓環境変数のpathにbinフォルダのpathを追加
image.png

powershell再起動後、

flutter --version

が通ればokです。

exe化(build)

先ほど作成したプロジェクトフォルダのディレクトリで

flet build windows

コマンドを入力します。
buildが成功すると下記のようになります。
image.png

buildフォルダを見ると、windowsというフォルダがあり、その中に.exeファイルがあると思います。
こちらが今回作成したデスクトップアプリケーションになります。
フォルダ毎配布することで、他の人が使用できる状態になります。

ちなみに、私の環境下では、下記のようなエラーが出ました。

 error GA230D127: The language version 3.9 specified for the package 'webview_flutter_android'
           is too high. The highest supported language version is 3.7.

どうやらwebview_flutter_androidのバージョンが高すぎたみたいです。こういう場合はtomlファイルを編集してあげればokです。
↓追記したもの

[tool.flet.flutter.pubspec.dependency_overrides]
webview_flutter_android = "3.7.1"

↓最終的なtomlファイル

[project]
name = "myapp"
version = "0.1.0"
description = ""
readme = "README.md"
requires-python = ">=3.9"
authors = [
    { name = "Flet developer", email = "you@example.com" }
]
dependencies = [
  "flet==0.28.3"
]

[tool.flet]
# org name in reverse domain name notation, e.g. "com.mycompany".
# Combined with project.name to build bundle ID for iOS and Android apps
org = "com.mycompany"

# project display name that is used as an app title on Android and iOS home screens,
# shown in window titles and about app dialogs on desktop.
product = "myapp"

# company name to display in about app dialogs
company = "Flet"

# copyright text to display in about app dialogs
copyright = "Copyright (C) 2025 by Flet"

[tool.flet.app]
path = "src"

[tool.uv]
dev-dependencies = [
    "flet[all]==0.28.3",
]

[tool.poetry]
package-mode = false

[tool.poetry.group.dev.dependencies]
flet = {extras = ["all"], version = "0.28.3"}
[tool.flet.flutter.pubspec.dependency_overrides]
webview_flutter_android = "3.7.1"

以上でexe化は終了です。お疲れ様でした。

最後に

今回はfletのexe化について説明しました。
tomlファイルについては依存ライブラリやライセンスなど、いろいろ記述できるので、アプリケーションに適した記述をする必要がありますね。

参考

2
4
0

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
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?