ちょっとしたWindowsツールを作る
あるルールに従って URL スキームを作ってQRコード化する業務があるり、今はそれを WSL 上の pythton スクリプトで行っているのだが、非エンジニアにとっては python の実行環境を作ることするら敷居が高い。なんならコマンドプロンプトすら無理。
GUI アプリを提供してあげたいところだが、業務で使える Visual Studio のライセンスもないし、いまさら Tinker を覚えるのもなぁ、と思っていたら、Flet なるものがよさげと聞いて試してみる。
The fastest way to build Flutter apps in Python
Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
とあり、 GUIアプリやフロントエンドの経験皆無な私でもどうにかなりそうな予感。
まずは Windows 環境に python をインストールする。
最新版 3.12 なんだー。
Add python.exe to PATH
のチェックがここになるのトラップ。見逃す。
PowerShell で python 動いた。
PS C:\Users\shasegawa> python -V
Python 3.12.0
仮想環境を作る。activate でエラー出た。
> python -m venv .venv
> .\.venv\Scripts\activate
.\.venv\Scripts\activate : このシステムではスクリプトの実行が無効になっているため、ファイル C:\Users\shas
egawa\works\20231115_flet\.venv\Scripts\Activate.ps1 を読み込むことができません。詳細については、「about_
Execution_Policies」(https://go.microsoft.com/fwlink/?LinkID=135170) を参照してください。
発生場所 行:1 文字:1
+ .\.venv\Scripts\activate
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : セキュリティ エラー: (: ) []、PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
そういや、PowerShell のスクリプトは標準では実行できないだった。
セキュリティ的に懸念はあるものの、システム全体でスクリプトの実行を許可してします。
管理者で PowerShell を開き実行。
Set-ExecutionPolicy RemoteSigned
pip で flet をインストール。
(.venv) PS C:\Users\shasegawa\works\20231115_flet> pip install flet
Collecting flet
Obtaining dependency information for flet from https://files.pythonhosted.org/packages/4a/c8/718cd4c7b056dc6ded8e8ba091d08a5e3a1d7187c9e0024f4c92d8bb5531/flet-0.12.0-py3-none-win_amd64.whl.metadata
Downloading flet-0.12.0-py3-none-win_amd64.whl.metadata (3.4 kB)
Collecting cookiecutter<3.0.0,>=2.4.0 (from flet)
Obtaining dependency information for cookiecutter<3.0.0,>=2.4.0 from https://files.pythonhosted.org/packages/f1/2d/9c36686df41cb196b0d7e5eef5c26fb964c2a77be40513535b481add5c87/cookiecutter-2.4.0-py3-none-any.whl.metadata
Downloading cookiecutter-2.4.0-py3-none-any.whl.metadata (7.0 kB)
Collecting flet-runtime==0.12.0 (from flet)
Obtaining dependency information for flet-runtime==0.12.0 from https://files.pythonhosted.org/packages/42/f7/9050cdc8724571a8f76f42abb15fb2ab9306c6138ebb57fae9fae8e64269/flet_runtime-0.12.0-py3-none-any.whl.metadata
Downloading flet_runtime-0.12.0-py3-none-any.whl.metadata (1.2 kB)
Collecting packaging<24.0,>=23.1 (from flet)
Obtaining dependency information for packaging<24.0,>=23.1 from https://files.pythonhosted.org/packages/ec/1a/610693ac4ee14fcdf2d9bf3c493370e4f2ef7ae2e19217d7a237ff42367d/packaging-23.2-py3-none-any.whl.metadata
Downloading packaging-23.2-py3-none-any.whl.metadata (3.2 kB)
Collecting qrcode<8.0.0,>=7.4.2 (from flet)
Downloading qrcode-7.4.2-py3-none-any.whl (46 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.2/46.2 kB 2.4 MB/s eta 0:00:00
Collecting watchdog<4.0.0,>=3.0.0 (from flet)
Downloading watchdog-3.0.0-py3-none-win_amd64.whl (82 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.0/82.0 kB 2.3 MB/s eta 0:00:00
Collecting websocket-client<2.0.0,>=1.5.2 (from flet)
Obtaining dependency information for websocket-client<2.0.0,>=1.5.2 from https://files.pythonhosted.org/packages/c4/3c/1892ce394828c43d4f65248ebdee3854114266b75d1f5915cb211155ad7b/websocket_client-1.6.4-py3-none-any.whl.metadata
Downloading websocket_client-1.6.4-py3-none-any.whl.metadata (7.7 kB)
Collecting websockets<12.0.0,>=11.0.3 (from flet)
Downloading websockets-11.0.3-py3-none-any.whl (118 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.1/118.1 kB 7.2 MB/s eta 0:00:00
Collecting flet-core==0.12.0 (from flet-runtime==0.12.0->flet)
Obtaining dependency information for flet-core==0.12.0 from https://files.pythonhosted.org/packages/09/09/0811d8fa28e85c0da93605ca368209c67844a1f45f563de23ad0552063f0/flet_core-0.12.0-py3-none-any.whl.metadata
Downloading flet_core-0.12.0-py3-none-any.whl.metadata (1.1 kB)
Collecting httpx<0.25.0,>=0.24.1 (from flet-runtime==0.12.0->flet)
Obtaining dependency information for httpx<0.25.0,>=0.24.1 from https://files.pythonhosted.org/packages/ec/91/e41f64f03d2a13aee7e8c819d82ee3aa7cdc484d18c0ae859742597d5aa0/httpx-0.24.1-py3-none-any.whl.metadata
Downloading httpx-0.24.1-py3-none-any.whl.metadata (7.4 kB)
Collecting oauthlib<4.0.0,>=3.2.2 (from flet-runtime==0.12.0->flet)
Downloading oauthlib-3.2.2-py3-none-any.whl (151 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.7/151.7 kB 9.4 MB/s eta 0:00:00
Collecting repath<0.10.0,>=0.9.0 (from flet-core==0.12.0->flet-runtime==0.12.0->flet)
Downloading repath-0.9.0-py3-none-any.whl (4.7 kB)
Collecting binaryornot>=0.4.4 (from cookiecutter<3.0.0,>=2.4.0->flet)
Downloading binaryornot-0.4.4-py2.py3-none-any.whl (9.0 kB)
Collecting Jinja2<4.0.0,>=2.7 (from cookiecutter<3.0.0,>=2.4.0->flet)
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 4.0 MB/s eta 0:00:00
Collecting click<9.0.0,>=7.0 (from cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for click<9.0.0,>=7.0 from https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl.metadata
Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting pyyaml>=5.3.1 (from cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for pyyaml>=5.3.1 from https://files.pythonhosted.org/packages/2b/9f/fbade56564ad486809c27b322d0f7e6a89c01f6b4fe208402e90d4443a99/PyYAML-6.0.1-cp312-cp312-win_amd64.whl.metadata
Downloading PyYAML-6.0.1-cp312-cp312-win_amd64.whl.metadata (2.1 kB)
Collecting python-slugify>=4.0.0 (from cookiecutter<3.0.0,>=2.4.0->flet)
Downloading python_slugify-8.0.1-py2.py3-none-any.whl (9.7 kB)
Collecting requests>=2.23.0 (from cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for requests>=2.23.0 from https://files.pythonhosted.org/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl.metadata
Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting arrow (from cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for arrow from https://files.pythonhosted.org/packages/f8/ed/e97229a566617f2ae958a6b13e7cc0f585470eac730a73e9e82c32a3cdd2/arrow-1.3.0-py3-none-any.whl.metadata
Downloading arrow-1.3.0-py3-none-any.whl.metadata (7.5 kB)
Collecting rich (from cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for rich from https://files.pythonhosted.org/packages/be/2a/4e62ff633612f746f88618852a626bbe24226eba5e7ac90e91dcfd6a414e/rich-13.6.0-py3-none-any.whl.metadata
Downloading rich-13.6.0-py3-none-any.whl.metadata (18 kB)
Collecting typing-extensions (from qrcode<8.0.0,>=7.4.2->flet)
Obtaining dependency information for typing-extensions from https://files.pythonhosted.org/packages/24/21/7d397a4b7934ff4028987914ac1044d3b7d52712f30e2ac7a2ae5bc86dd0/typing_extensions-4.8.0-py3-none-any.whl.metadata
Downloading typing_extensions-4.8.0-py3-none-any.whl.metadata (3.0 kB)
Collecting pypng (from qrcode<8.0.0,>=7.4.2->flet)
Downloading pypng-0.20220715.0-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.1/58.1 kB 3.0 MB/s eta 0:00:00
Collecting colorama (from qrcode<8.0.0,>=7.4.2->flet)
Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting chardet>=3.0.2 (from binaryornot>=0.4.4->cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for chardet>=3.0.2 from https://files.pythonhosted.org/packages/38/6f/f5fbc992a329ee4e0f288c1fe0e2ad9485ed064cac731ed2fe47dcc38cbf/chardet-5.2.0-py3-none-any.whl.metadata
Downloading chardet-5.2.0-py3-none-any.whl.metadata (3.4 kB)
Collecting certifi (from httpx<0.25.0,>=0.24.1->flet-runtime==0.12.0->flet)
Obtaining dependency information for certifi from https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl.metadata
Downloading certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
Collecting httpcore<0.18.0,>=0.15.0 (from httpx<0.25.0,>=0.24.1->flet-runtime==0.12.0->flet)
Obtaining dependency information for httpcore<0.18.0,>=0.15.0 from https://files.pythonhosted.org/packages/94/2c/2bde7ff8dd2064395555220cbf7cba79991172bf5315a07eb3ac7688d9f1/httpcore-0.17.3-py3-none-any.whl.metadata
Downloading httpcore-0.17.3-py3-none-any.whl.metadata (18 kB)
Collecting idna (from httpx<0.25.0,>=0.24.1->flet-runtime==0.12.0->flet)
Downloading idna-3.4-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 3.2 MB/s eta 0:00:00
Collecting sniffio (from httpx<0.25.0,>=0.24.1->flet-runtime==0.12.0->flet)
Downloading sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting MarkupSafe>=2.0 (from Jinja2<4.0.0,>=2.7->cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for MarkupSafe>=2.0 from https://files.pythonhosted.org/packages/44/44/dbaf65876e258facd65f586dde158387ab89963e7f2235551afc9c2e24c2/MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl.metadata
Downloading MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl.metadata (3.0 kB)
Collecting text-unidecode>=1.3 (from python-slugify>=4.0.0->cookiecutter<3.0.0,>=2.4.0->flet)
Downloading text_unidecode-1.3-py2.py3-none-any.whl (78 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.2/78.2 kB 4.5 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2 (from requests>=2.23.0->cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for charset-normalizer<4,>=2 from https://files.pythonhosted.org/packages/b6/7c/8debebb4f90174074b827c63242c23851bdf00a532489fba57fef3416e40/charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl.metadata
Downloading charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl.metadata (34 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.23.0->cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for urllib3<3,>=1.21.1 from https://files.pythonhosted.org/packages/96/94/c31f58c7a7f470d5665935262ebd7455c7e4c7782eb525658d3dbf4b9403/urllib3-2.1.0-py3-none-any.whl.metadata
Downloading urllib3-2.1.0-py3-none-any.whl.metadata (6.4 kB)
Collecting python-dateutil>=2.7.0 (from arrow->cookiecutter<3.0.0,>=2.4.0->flet)
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 5.1 MB/s eta 0:00:00
Collecting types-python-dateutil>=2.8.10 (from arrow->cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for types-python-dateutil>=2.8.10 from https://files.pythonhosted.org/packages/1c/af/5af2e2a02bc464c1c7818c260606343020b96c0d5b64f637d9e91aee24fe/types_python_dateutil-2.8.19.14-py3-none-any.whl.metadata
Downloading types_python_dateutil-2.8.19.14-py3-none-any.whl.metadata (1.6 kB)
Collecting markdown-it-py>=2.2.0 (from rich->cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for markdown-it-py>=2.2.0 from https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl.metadata
Downloading markdown_it_py-3.0.0-py3-none-any.whl.metadata (6.9 kB)
Collecting pygments<3.0.0,>=2.13.0 (from rich->cookiecutter<3.0.0,>=2.4.0->flet)
Obtaining dependency information for pygments<3.0.0,>=2.13.0 from https://files.pythonhosted.org/packages/43/88/29adf0b44ba6ac85045e63734ae0997d3c58d8b1a91c914d240828d0d73d/Pygments-2.16.1-py3-none-any.whl.metadata
Downloading Pygments-2.16.1-py3-none-any.whl.metadata (2.5 kB)
Collecting h11<0.15,>=0.13 (from httpcore<0.18.0,>=0.15.0->httpx<0.25.0,>=0.24.1->flet-runtime==0.12.0->flet)
Downloading h11-0.14.0-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB ? eta 0:00:00
Collecting anyio<5.0,>=3.0 (from httpcore<0.18.0,>=0.15.0->httpx<0.25.0,>=0.24.1->flet-runtime==0.12.0->flet)
Obtaining dependency information for anyio<5.0,>=3.0 from https://files.pythonhosted.org/packages/36/55/ad4de788d84a630656ece71059665e01ca793c04294c463fd84132f40fe6/anyio-4.0.0-py3-none-any.whl.metadata
Downloading anyio-4.0.0-py3-none-any.whl.metadata (4.5 kB)
Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich->cookiecutter<3.0.0,>=2.4.0->flet)
Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Collecting six>=1.5 (from python-dateutil>=2.7.0->arrow->cookiecutter<3.0.0,>=2.4.0->flet)
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Downloading flet-0.12.0-py3-none-win_amd64.whl (22.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 22.9/22.9 MB 8.3 MB/s eta 0:00:00
Downloading flet_runtime-0.12.0-py3-none-any.whl (22 kB)
Downloading flet_core-0.12.0-py3-none-any.whl (260 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 260.1/260.1 kB 16.7 MB/s eta 0:00:00
Downloading cookiecutter-2.4.0-py3-none-any.whl (38 kB)
Downloading packaging-23.2-py3-none-any.whl (53 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.0/53.0 kB ? eta 0:00:00
Downloading websocket_client-1.6.4-py3-none-any.whl (57 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.3/57.3 kB 2.9 MB/s eta 0:00:00
Downloading click-8.1.7-py3-none-any.whl (97 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 5.5 MB/s eta 0:00:00
Downloading httpx-0.24.1-py3-none-any.whl (75 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.4/75.4 kB 4.1 MB/s eta 0:00:00
Downloading PyYAML-6.0.1-cp312-cp312-win_amd64.whl (138 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 138.7/138.7 kB ? eta 0:00:00
Downloading requests-2.31.0-py3-none-any.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 3.5 MB/s eta 0:00:00
Downloading arrow-1.3.0-py3-none-any.whl (66 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.4/66.4 kB 3.5 MB/s eta 0:00:00
Downloading rich-13.6.0-py3-none-any.whl (239 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 239.8/239.8 kB 5.0 MB/s eta 0:00:00
Downloading typing_extensions-4.8.0-py3-none-any.whl (31 kB)
Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 kB 9.9 MB/s eta 0:00:00
Downloading chardet-5.2.0-py3-none-any.whl (199 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.4/199.4 kB 11.8 MB/s eta 0:00:00
Downloading charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl (100 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.4/100.4 kB 5.6 MB/s eta 0:00:00
Downloading httpcore-0.17.3-py3-none-any.whl (74 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 74.5/74.5 kB ? eta 0:00:00
Downloading markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.5/87.5 kB ? eta 0:00:00
Downloading MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl (16 kB)
Downloading Pygments-2.16.1-py3-none-any.whl (1.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 9.2 MB/s eta 0:00:00
Downloading types_python_dateutil-2.8.19.14-py3-none-any.whl (9.4 kB)
Downloading urllib3-2.1.0-py3-none-any.whl (104 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.6/104.6 kB 6.3 MB/s eta 0:00:00
Downloading anyio-4.0.0-py3-none-any.whl (83 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.1/83.1 kB ? eta 0:00:00
Installing collected packages: types-python-dateutil, text-unidecode, pypng, websockets, websocket-client, watchdog, urllib3, typing-extensions, sniffio, six, pyyaml, python-slugify, pygments, packaging, oauthlib, mdurl, MarkupSafe, idna, h11, colorama, charset-normalizer, chardet, certifi, requests, repath, qrcode, python-dateutil, markdown-it-py, Jinja2, click, binaryornot, anyio, rich, httpcore, flet-core, arrow, httpx, cookiecutter, flet-runtime, flet
Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.3 anyio-4.0.0 arrow-1.3.0 binaryornot-0.4.4 certifi-2023.7.22 chardet-5.2.0 charset-normalizer-3.3.2 click-8.1.7 colorama-0.4.6 cookiecutter-2.4.0 flet-0.12.0 flet-core-0.12.0 flet-runtime-0.12.0 h11-0.14.0 httpcore-0.17.3 httpx-0.24.1 idna-3.4 markdown-it-py-3.0.0 mdurl-0.1.2 oauthlib-3.2.2 packaging-23.2 pygments-2.16.1 pypng-0.20220715.0 python-dateutil-2.8.2 python-slugify-8.0.1 pyyaml-6.0.1 qrcode-7.4.2 repath-0.9.0 requests-2.31.0 rich-13.6.0 six-1.16.0 sniffio-1.3.0 text-unidecode-1.3 types-python-dateutil-2.8.19.14 typing-extensions-4.8.0 urllib3-2.1.0 watchdog-3.0.0 websocket-client-1.6.4 websockets-11.0.3
[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
pip もバージョンアップしろとか言われているのでしておく。
(.venv) PS C:\Users\shasegawa\works\20231115_flet> python.exe -m pip install --upgrade pip
Requirement already satisfied: pip in c:\users\shasegawa\works\20231115_flet\.venv\lib\site-packages (23.2.1)
Collecting pip
Obtaining dependency information for pip from https://files.pythonhosted.org/packages/47/6a/453160888fab7c6a432a6e25f8afe6256d0d9f2cbd25971021da6491d899/pip-23.3.1-py3-none-any.whl.metadata
Downloading pip-23.3.1-py3-none-any.whl.metadata (3.5 kB)
Downloading pip-23.3.1-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 8.4 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.2.1
Uninstalling pip-23.2.1:
Successfully uninstalled pip-23.2.1
Successfully installed pip-23.3.1
とりあえず、公式のサンプルを動かしてみる。
import flet as ft
def main(page: ft.Page):
page.title = "Flet counter example"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)
def minus_click(e):
txt_number.value = str(int(txt_number.value) - 1)
page.update()
def plus_click(e):
txt_number.value = str(int(txt_number.value) + 1)
page.update()
page.add(
ft.Row(
[
ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
txt_number,
ft.IconButton(ft.icons.ADD, on_click=plus_click),
],
alignment=ft.MainAxisAlignment.CENTER,
)
)
ft.app(target=main)
python counter.py
であっさり動く。
細かい使い方は後回しにして、exeファイルが作れるか試してみる。
最初に pyinstaller
をインストールする。
(.venv) PS C:\Users\shasegawa\works\20231115_flet> pip install pyinstaller
Collecting pyinstaller
Downloading pyinstaller-6.2.0-py3-none-win_amd64.whl.metadata (8.3 kB)
Collecting setuptools>=42.0.0 (from pyinstaller)
Downloading setuptools-68.2.2-py3-none-any.whl.metadata (6.3 kB)
Collecting altgraph (from pyinstaller)
Downloading altgraph-0.17.4-py2.py3-none-any.whl.metadata (7.3 kB)
Collecting pyinstaller-hooks-contrib>=2021.4 (from pyinstaller)
Downloading pyinstaller_hooks_contrib-2023.10-py2.py3-none-any.whl.metadata (15 kB)
Requirement already satisfied: packaging>=22.0 in c:\users\shasegawa\works\20231115_flet\.venv\lib\site-packages (from pyinstaller) (23.2)
Collecting pefile>=2022.5.30 (from pyinstaller)
Downloading pefile-2023.2.7-py3-none-any.whl (71 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 71.8/71.8 kB 3.8 MB/s eta 0:00:00
Collecting pywin32-ctypes>=0.2.1 (from pyinstaller)
Downloading pywin32_ctypes-0.2.2-py3-none-any.whl.metadata (3.8 kB)
Downloading pyinstaller-6.2.0-py3-none-win_amd64.whl (1.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 6.3 MB/s eta 0:00:00
Downloading pyinstaller_hooks_contrib-2023.10-py2.py3-none-any.whl (288 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 288.4/288.4 kB 3.6 MB/s eta 0:00:00
Downloading pywin32_ctypes-0.2.2-py3-none-any.whl (30 kB)
Downloading setuptools-68.2.2-py3-none-any.whl (807 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 807.9/807.9 kB 7.3 MB/s eta 0:00:00
Downloading altgraph-0.17.4-py2.py3-none-any.whl (21 kB)
Installing collected packages: altgraph, setuptools, pywin32-ctypes, pyinstaller-hooks-contrib, pefile, pyinstaller
Successfully installed altgraph-0.17.4 pefile-2023.2.7 pyinstaller-6.2.0 pyinstaller-hooks-contrib-2023.10 pywin32-ctypes-0.2.2 setuptools-68.2.2
flet pack
すればいいらしい。
(.venv) PS C:\Users\shasegawa\works\20231115_flet> flet pack counter.py
Updating Flet View version info C:\Users\SHASEG~1\AppData\Local\Temp\9f8827f5-181b-4415-8ac2-0b85e2e6bee6\flet\flet.exe
Running PyInstaller: ['counter.py', '--noconsole', '--noconfirm', '--onefile', '--version-file', 'C:\\Users\\SHASEG~1\\AppData\\Local\\Temp\\45a9e03e-d68d-4b49-98d4-88ea437562e3']
904 INFO: PyInstaller: 6.2.0
904 INFO: Python: 3.12.0
927 INFO: Platform: Windows-11-10.0.22621-SP0
928 INFO: wrote C:\Users\shasegawa\works\20231115_flet\counter.spec
935 INFO: Extending PYTHONPATH with paths
['C:\\Users\\shasegawa\\works\\20231115_flet']
1561 INFO: checking Analysis
1561 INFO: Building Analysis because Analysis-00.toc is non existent
1561 INFO: Initializing module dependency graph...
1568 INFO: Caching module graph hooks...
1597 INFO: Analyzing base_library.zip ...
2622 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\shasegawa\\works\\20231115_flet\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
2689 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\shasegawa\\works\\20231115_flet\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
4006 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\shasegawa\\works\\20231115_flet\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
5901 INFO: Caching module dependency graph...
5979 INFO: Running Analysis Analysis-00.toc
5979 INFO: Looking for Python shared library...
5982 INFO: Using Python shared library: C:\Users\shasegawa\AppData\Local\Programs\Python\Python312\python312.dll
5982 INFO: Analyzing C:\Users\shasegawa\works\20231115_flet\counter.py
5986 INFO: Loading module hook 'hook-flet.py' from 'C:\\Users\\shasegawa\\works\\20231115_flet\\.venv\\Lib\\site-packages\\flet\\__pyinstaller'...
6109 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\shasegawa\\works\\20231115_flet\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
6293 INFO: Loading module hook 'hook-multiprocessing.util.py' from
... (snip) ...
17220 INFO: Warnings written to C:\Users\shasegawa\works\20231115_flet\build\counter\warn-counter.txt
17301 INFO: Graph cross-reference written to C:\Users\shasegawa\works\20231115_flet\build\counter\xref-counter.html
17335 INFO: checking PYZ
17335 INFO: Building PYZ because PYZ-00.toc is non existent
17335 INFO: Building PYZ (ZlibArchive) C:\Users\shasegawa\works\20231115_flet\build\counter\PYZ-00.pyz
18318 INFO: Building PYZ (ZlibArchive) C:\Users\shasegawa\works\20231115_flet\build\counter\PYZ-00.pyz completed successfully.
18366 INFO: checking PKG
18366 INFO: Building PKG because PKG-00.toc is non existent
18366 INFO: Building PKG (CArchive) counter.pkg
25362 INFO: Building PKG (CArchive) counter.pkg completed successfully.
25364 INFO: Bootloader C:\Users\shasegawa\works\20231115_flet\.venv\Lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\runw.exe
25364 INFO: checking EXE
25364 INFO: Building EXE because EXE-00.toc is non existent
25365 INFO: Building EXE from EXE-00.toc
25365 INFO: Copying bootloader EXE to C:\Users\shasegawa\works\20231115_flet\dist\counter.exe
25468 INFO: Copying icon to EXE
25526 INFO: Copying version information to EXE
25585 INFO: Copying 0 resources to EXE
25585 INFO: Embedding manifest in EXE
25640 INFO: Appending PKG archive to EXE
25661 INFO: Fixing EXE headers
26068 INFO: Building EXE from EXE-00.toc completed successfully.
Deleting temp directory: C:\Users\SHASEG~1\AppData\Local\Temp\9f8827f5-181b-4415-8ac2-0b85e2e6bee6
なにやら warning が大量に出ているが、exe ファイルはできたっぽい。
(.venv) PS C:\Users\shasegawa\works\20231115_flet> ls dist
ディレクトリ: C:\Users\shasegawa\works\20231115_flet\dist
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2023/11/15 23:09 35668775 counter.exe
exe ファイルも問題なく実行できた。
Warning はこんな感じのが大量に出ている。
17182 WARNING: Library not found: could not resolve 'api-ms-win-crt-heap-l1-1-0.dll', dependency of 'C:\\Users\\SHASEG~1\\AppData\\Local\\Temp\\9f8827f5-181b-4415-8ac2-0b85e2e6bee6\\flet\\vcruntime140_1.dll'.
17183 WARNING: Library not found: could not resolve 'api-ms-win-crt-runtime-l1-1-0.dll', dependency of 'C:\\Users\\SHASEG~1\\AppData\\Local\\Temp\\9f8827f5-181b-4415-8ac2-0b85e2e6bee6\\flet\\vcruntime140_1.dll'.
17183 WARNING: Library not found: could not resolve 'api-ms-win-crt-string-l1-1-0.dll', dependency of 'C:\\Users\\SHASEG~1\\AppData\\Local\\Temp\\9f8827f5-181b-4415-8ac2-0b85e2e6bee6\\flet\\vcruntime140_1.dll'.
17184 WARNING: Library not found: could not resolve 'api-ms-win-crt-heap-l1-1-0.dll', dependency of 'C:\\Users\\SHASEG~1\\AppData\\Local\\Temp\\9f8827f5-181b-4415-8ac2-0b85e2e6bee6\\flet\\window_manager_plugin.dll'.
17184 WARNING: Library not found: could not resolve 'api-ms-win-crt-runtime-l1-1-0.dll', dependency of 'C:\\Users\\SHASEG~1\\AppData\\Local\\Temp\\9f8827f5-181b-4415-8ac2-0b85e2e6bee6\\flet\\window_manager_plugin.dll'.
17184 WARNING: Library not found: could not resolve 'api-ms-win-crt-heap-l1-1-0.dll', dependency of 'C:\\Users\\SHASEG~1\\AppData\\Local\\Temp\\9f8827f5-181b-4415-8ac2-0b85e2e6bee6\\flet\\url_launcher_windows_plugin.dll'.
17184 WARNING: Library not found: could not resolve 'api-ms-win-crt-runtime-l1-1-0.dll', dependency of 'C:\\Users\\SHASEG~1\\AppData\\Local\\Temp\\9f8827f5-181b-4415-8ac2-0b85e2e6bee6\\flet\\url_launcher_windows_plugin.dll'.
https://github.com/pyinstaller/pyinstaller/issues/4047 が現象としては似ているが、ちょっと古い話。
VC++のランタイムライセンスとかその辺のはなし??
とりあえずは動ていているけど、無視していいのかな??
をインストールしてみて何か変わるか?
うぅ、再起動を求められる。
結果は変わらず。
api-ms-win-crt-runtime-l1-1-0.dll
で検索してもユニバーサルCランタイムをインストールしろとか出てくるのだが、 Windows 8.1 とかその時代の話。
手詰まりなので、問題がでたらその時また調べる。