LoginSignup
15
19

More than 5 years have passed since last update.

PyQt5で作成したアプリケーションをPyInstallerでEXE化する

Last updated at Posted at 2017-03-22

ざっくり言うと

  • PyQt5を用いたGUIアプリケーションをPyInstallerでWindowsのEXE化する際にハマった
  • ビルド時にPyQtのパスを指定することで、ビルドが通る

状況

PyQt5を用いてGUIアプリケーションを作成していた。
アプリケーションは、ウインドウにドラッグアンドドロップされたファイルの解析を行い、エクセル形式でファイルを出力するというものである。
配布するために、EXE化しようと思ってPyInstallerを用いたところ、ビルドは成功するが実行できない。

実行時のエラーメッセージは failed to execute script pyi_rth_qt5plugins

環境については、

  • Windows 10
  • Python (3.5.3)
    • future (0.16.0)
    • PyInstaller (3.2.1)
    • pypiwin32 (219)
    • PyQt5 (5.8.1)
    • sip (4.19.1)
    • XlsxWriter (0.9.6)

対策

pyinstaller実行時にPyQtのパスを設定する。

pyinstaller simple_tool.py --onefile --noconsole -p "C:\Users\ユーザ名\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\PyQt5\Qt\bin"

-pでsite-packages以下のPyQtライブラリファイルのディレクトリを指定する。

Pythonがインストールされているディレクトリは環境によりけりなので、適宜参照。

15
19
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
15
19