問題描述
我正在嘗試從我的代碼中創(chuàng)建一個使用 PyQt5 的可執(zhí)行文件.我正在使用 Python 3.5.3 -64 位,在 Windows 10 中開發(fā),使用 pip 安裝 pyinstaller 3.2.1,并安裝了 pywin32.Pyinstaller 運行但輸出未找到庫的警告.
I'm trying create an executable from my code that uses PyQt5. I'm using Python 3.5.3 -64 bits, developing in Windows 10, used pip to install pyinstaller 3.2.1, and installed pywin32. Pyinstaller runs but outputs warnings that libraries aren't found.
我正在使用以下內(nèi)容創(chuàng)建我的應(yīng)用程序:
I'm creating my application using the following:
pyinstaller Start_UI.py
輸出這些警告.
pyinstaller Start_UI.spec
哪些輸出這些警告
當我打開 pyinstaller 創(chuàng)建的可執(zhí)行文件時,應(yīng)用程序會立即關(guān)閉.我懷疑應(yīng)用程序由于警告而失敗.如何解決警告以使可執(zhí)行文件正常工作?
When I open the executable that pyinstaller creates, the application closes immediately. I suspect the application is failing because of the warnings. How can I resolve the warnings so the executable works?
感謝您的回復(fù).
我在我的計算機上搜索 DLL 文件并將它們復(fù)制到 dist 文件夾中,該文件夾通過以下方式解決了警告輸出:
I searched for DLL files on my computer and copied them into the dist folder which resolved the warnings output by:
pyinstaller Start_UI.py
至于:
pyinstaller Start_UI.spec
我在我的 Windows SDK 安裝中找到了任務(wù) api-mis-win-crt-* dll 文件,并將它們也復(fù)制到了 dist 中.這一次,警告沒有得到解決,因為 pyinstaller 找不到 dll 文件.我需要將 api dll 文件放在哪里以便 pyinstaller 找到它們?
I located the mission api-mis-win-crt-* dll files in my installation of Windows SDK, and copied them into dist as well. This time, the warnings were not resolved as pyinstaller can't locate the dll files. Where do I need to put the api dll files for pyinstaller to locate them?
推薦答案
經(jīng)過大量研究,問題出在 Windows 10 上.雖然我沒有找到 Windows 10 解決方案,但我確實在 Windows 7 中解決了我的問題.
After a lot of research, the problem is because of Windows 10. While I didn't find a Windows 10 solution, I did solve my problem in Windows 7.
我在 Windows 7 上測試了 pyinstaller,但仍然收到警告,但不是 api-ms-win-crt-*.dll 警告.
I tested pyinstaller on Windows 7 and was still getting warnings, but not the api-ms-win-crt-*.dll warnings.
我將 Python35 目錄中的所有 dll 文件復(fù)制到 pyinstaller 生成的 dist 文件夾中.至此,pyinstaller 可以將 Hello World 程序無錯誤地轉(zhuǎn)為可執(zhí)行文件:
I copied all the dll files in my Python35 directory into the pyinstaller generated dist folder. At this point, pyinstaller can turn a Hello World program into an executable without errors:
pyinstaller --onefile Hello_World.py
但是,將 PyQt5 程序轉(zhuǎn)換為可執(zhí)行文件會出錯,因為 pyinstaller 無法找到 Qt5*.dll 文件.要修復(fù)此問題,請將 Lib/site-packages/PyQt5/Qt/bin 下的 PyQt5、Qt5*.dll 文件復(fù)制到 dist.然后告訴 pyinstaller dll 文件在哪里使用 --path:
However, turning a PyQt5 program into an executable gives errors because pyinstaller can't locate the Qt5*.dll files. To fix this copy the PyQt5, Qt5*.dll files, under Lib/site-packages/PyQt5/Qt/bin and into dist. Then tell pyinstaller where the dll files are using --path:
pyinstaller --onefile --path dist Start_UI.py
這會在 dist 中創(chuàng)建一個可以工作的可執(zhí)行 Start_UI.exe.
This creates a working executable Start_UI.exe in dist.
這篇關(guān)于Pyinstaller:警告:找不到庫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!