我試圖從我的代碼使用PyQt5創建一個可執行文件。我使用Python 3.5.3 -64位,在Windows 10中開發,並使用pip來安裝pyinstaller 3.2.1。Pyinstaller:導入錯誤:DLL加載失敗:無法找到指定的模塊
我跑這樣pyinstaller:
pyinstaller.exe --onefile --windowed main.py
我得到一個導入錯誤:
File "C:\Python35\Scripts\pyinstaller-script.py", line 11, in <module> load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
File "C:\Python35\lib\site-packages\pkg_resources\__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Python35\lib\site-packages\pkg_resources\__init__.py", line 2631, in load_entry_point
return ep.load()
File "C:\Python35\lib\site-packages\pkg_resources\__init__.py", line 2291, in load
return self.resolve()
File "C:\Python35\lib\site-packages\pkg_resources\__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "C:\Python35\lib\site-packages\PyInstaller\__main__.py", line 21, in <module>
import PyInstaller.building.build_main
File "C:\Python35\lib\site-packages\PyInstaller\building\build_main.py", line 32, in <module>
from ..depend import bindepend
File "C:\Python35\lib\site-packages\PyInstaller\depend\bindepend.py", line 38, in <module>
from ..utils.win32.winmanifest import RT_MANIFEST
File "C:\Python35\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 97, in <module>
from PyInstaller.utils.win32 import winresource
File "C:\Python35\lib\site-packages\PyInstaller\utils\win32\winresource.py", line 20, in <module>
import pywintypes
File "C:\Python35\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:\Python35\lib\site-packages\win32\lib\pywintypes.py", line 64, in __import_pywin32_system_module__
import _win32sysloader
ImportError: DLL load failed: The specified module could not be found.
我讀過這個意義pywin32不是由PIP和安裝我需要安裝此Microsoft Visual Package:https://www.microsoft.com/en-us/download/details.aspx?id=5555。我下載並安裝它,但我得到相同的錯誤。
編輯:
從sourceforge.net/projects/pywin32/files/pywin32/Build%20221安裝pywin32後,導入錯誤消失,但是當它運行我得到警告(輸出數百行的長,這裏是一個片段):
pyinstaller main.py
....
3220 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\Python35\python.exe
3251 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Python35\python.exe
3267 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\Python35\python.exe
3305 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\Python35\python.exe
3336 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of C:\Python35\python.exe
....
9265 WARNING: lib not found: Qt5Core.dll dependency of C:\Python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
9297 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\Python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
9333 WARNING: lib not found: Qt5Gui.dll dependency of C:\Python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
9366 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\Python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
然後我運行:
pyinstaller main.spec
,並得到了類似的警告。生成的exe文件立即關閉。
嘗試在沒有窗口的情況下運行它,或者使用spec文件代替 –
在沒有窗口的情況下運行它不起作用。什麼是spec文件? – Jaitnium
運行'''pyinstaller file.py'''然後創建一個名爲'''file.spec''的文件 –