1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

令和最新版FletがWindowsで動かない

Last updated at Posted at 2023-02-19

症状

Fletでスタンドアローンアプリを作ろうとするとエラーが出る。

(base) (venv) PS > flet pack main.py      
Please install PyInstaller module to use flet pack command: cannot import name 'decode' from 'PyInstaller.utils.win32.versioninfo' (C:\Users\...\PycharmProjects\myflet\venv\lib\site-packages\PyInstaller\utils\win32\versioninfo.py)

エラーの出た環境

  • pyinstaller==5.8.0
  • flet==0.3.2及びflet==0.4.0
  • Windows(Windows11 64bitで問題を確認した)

解決方法

  • 問題はpyinstallerの更新にFletが追い付いていないこと。そこで令和旧世代版pyinstaller(pyinstaller==5.7.0)にダウングレードする。
    > pip install -U pyinstaller==5.7.0
    
  • もう一度トライ
    (base) (venv) PS > flet pack main.py
    Updating Flet View version info C:\Users\...\AppData\Local\Temp\71ad1c64-0828-4ba6-932e-877610594e7e\flet\flet.exe
    (省略)
    22846 INFO: Building EXE from EXE-00.toc completed successfully.
    Deleting temp directory: C:\Users\...\AppData\Local\Temp\71ad1c64-0828-4ba6-932e-877610594e7e
    
    きちんと動いた

Windowsだけの問題だと思います。

問題の原因

Fletに問題がある

  • エラーの発生個所
    flet__pyinstaller\win_utils.py
    from PyInstaller.utils.win32.versioninfo import decode
    
    PyInstaller 5.7.0から5.8.0への変更時にversioninfoのdecode関数の名前がread_version_info_from_executableに変更になったため、関数が存在しないとのエラーが発生している。下記のコミットの影響
    https://github.com/pyinstaller/pyinstaller/commit/f57e15ae14d2370cba7a14cfae97d2c29b5c8154
  • こうすれば動く
    # from PyInstaller.utils.win32.versioninfo import decode
    from PyInstaller.utils.win32.versioninfo import read_version_info_from_executable as decode
    
    GithubにIssueがあった。flet==0.4.1で直るらしい。
    https://github.com/flet-dev/flet/issues/1031
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?