1. 程式人生 > >解決This application failed to start because it could not find or load the Qt platform plugin "windows

解決This application failed to start because it could not find or load the Qt platform plugin "windows

PyQt5+python做UI時,使用pyinstaller打包成exe,點選執行exe檔案時,出現This application failed to start because it could not find or load the Qt platform plugin "windows錯誤。


問題是,缺少必要的dll檔案,我們找到路徑:C:\ANACONDA\Lib\site-packages\PyQt5\Qt\plugins(這是我的安裝路徑),在此資料夾下找到platforms資料夾,然後拷貝整個資料夾,將其放到與exe相同的路徑下,這時候就可以執行exe了。

注意:

1.雖然在開始生成exe檔案時,會包含一個PyQt5資料夾,這裡面也有一個platforms資料夾,可是把這個資料夾拷貝出來並不可行。

2.如果設計的UI採用介面與邏輯分離,也就是多個python檔案時,使用pyinstaller執行main函式所在的python檔案即可。