皆さん、こんにちは。
PythonのPyinstallerでexeファイル生成中に以下のエラーが表示されてしまい困っていましたが、解決できましたので、その解決方法を紹介します。
事象
以下のコマンドを実行中にエラーが発生
pyinstaller sample.py --onefile --noconsole
エラーは以下の内容
**win32ctypes.pywin32.pywintypes.error: (225, 'BeginUpdateResourceW', 'Operation did not complete successfully because the file contains a virus or potentially unwanted software.')**
試したけど、うまくいかなかったこと
Windows Defenderのエラーも出ることがあったので、こちらの記事を参考に「bootloaderを再構築する」ということを試しましたが、うまくいきませんでした。

【Pyinstaller】Windows Defenderに引っかからないようにする - Qiita
背景Pythonでデスクトップアプリを作成することがあり、exe化にpyinstallerを使用pyinstallerコマンド(pyinstaller hoge.py)でexe化したときに、wi…
解決方法
解決方法は単純にバージョンダウンするだけです。
# アンインストール
pip uninstall pyinstaller
# 前のバージョンのインストール
pip install pyinstaller==5.13.2
どうやら6.3.0や6.0.0で同様のエラーが発生しているようで、バージョンによるバグか何かが原因のようです。
参考

*win32ctypes.pywin32.pywintypes.error when using pyinstaller in VS Code - Possible Virus/Trojan?
I am using pyinstaller to generate an executable code for my python.py file. However, I am getting this error: File "C:\Users\xxxxx\AppData\Local\Programs\...
コメント