デバッグ用のシンプルなfletプロジェクト
pygsheetsというライブラリを呼ぶとエラーになります。
https://drive.google.com/file/d/1_FFtnHXDH4ZjCQqPyEjrXCWn8lB3RWIA/view?usp=sharing
エラータイトル:
ModuleNotFoundError: No module named 'wsgiref'
環境:
- OS: macOS Sonoma 14.5
- Flet バージョン: 0.25.2
- Python バージョン: 3.12.5
再現手順:
flet build macos
でFletアプリをビルド- ビルドしたアプリケーションを実行
- 起動直後にエラーが発生
期待される動作:
- アプリケーションがモジュールインポートエラーなく正常に起動すること
追加情報:
- Google Sheets連携のためにpygsheetsを使用
- 開発モードでは問題なく動作
- ビルド/パッケージング版でのみエラーが発生
質問事項:
- Google OAuth を使用する Flet アプリケーションのパッケージング時の既知の問題でしょうか?
- ビルドパッケージに wsgiref モジュールを正しく含める方法はありますか?
- 回避策や代替アプローチはありますか?
コードサンプル
Traceback (most recent call last): File "<string>", line 47, in <module> File "<frozen runpy>", line 229, in run_module File "<frozen runpy>", line 88, in _run_code File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/main.py", line 4, in <module> from screen_settings import SettingsScreen File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/screen_settings.py", line 6, in <module> from service_config_checker import ServiceConfigChecker File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/service_config_checker.py", line 3, in <module> from service_sheet import ServiceSheet File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/service_sheet.py", line 4, in <module> import pygsheets File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/__pypackages__/pygsheets/__init__.py", line 14, in <module> from pygsheets.authorization import authorize File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/__pypackages__/pygsheets/authorization.py", line 8, in <module> from google_auth_oauthlib.flow import Flow, InstalledAppFlow File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/__pypackages__/google_auth_oauthlib/__init__.py", line 21, in <module> from .interactive import get_user_credentials File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/__pypackages__/google_auth_oauthlib/interactive.py", line 27, in <module> import google_auth_oauthlib.flow File "/Users/myAccount/Library/Application Support/com.mycompany.myAppName/flet/app/__pypackages__/google_auth_oauthlib/flow.py", line 62, in <module> import wsgiref.simple_server ModuleNotFoundError: No module named 'wsgiref'
main.py
import flet as ft from google.oauth2.credentials import Credentials from google.oauth2 import service_account from google.auth.transport.requests import Request import pygsheets def main(page: ft.Page): page.title = "Flet App with Side Menu" page.padding = 0 page.theme_mode = "light" page.add(ft.Text("Hello, World!")) ft.app(target=main)
pyproject.toml
[project] name = "myapp" version = "0.1.0" description = "" readme = "README.md" requires-python = ">=3.8" dependencies = [ "flet==0.25.2", "google-auth-oauthlib==1.1.0", "pygsheets==2.0.6", ] [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) 2024 by Flet" [tool.flet.app] path = "src"
あなたの回答
tips
プレビュー