こんにちは、家庭内エンジニアのネコヤナギ🐈です。
Amazonのペイメントの過去の決済情報レポートデータから軽減税率分の売上高と税金を計算するためにツールを作成しました。
【tkinter でテキストファイルをドラッグアンドドロップしたら計算結果が出る】という構造にしたところ、exe化する際に少しだけ躓いたのでシェアします。
実行環境
windows10 home
python3.12
exe化に使ったのは pyinstaller です。
tkdndパッケージが見つからない
Traceback (most recent call last):
File "tkinterdnd2\TkinterDnD.py", line 53, in _require
_tkinter.TclError: can't find package tkdnd
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 34, in <module>
File "tkinterdnd2\TkinterDnD.py", line 285, in __init__
File "tkinterdnd2\TkinterDnD.py", line 55, in _require
RuntimeError: Unable to load tkdnd library.
実行したコードは下記のものです。
pyinstaller main.py --onefile --noconsole
解決策
一度pyinstallerで生成されたファイルを消してから下記のコードで実行したところ、無事exe化ができました。
ただ、37MBとあまりにも大きいサイズなので、今度は軽量化が課題になりました。
pyinstaller main.py --onefile --noconsole --collect-data tkinterdnd2
コメント