Pyinstaller: Import Error: DLL load failed: The specified module could not be found

霸气de小男生 提交于 2021-02-05 05:56:07

问题


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, and used pip to install pyinstaller 3.2.1.

I run pyinstaller as such:

pyinstaller.exe --onefile --windowed main.py

I get an Import Error:

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.

I've read that this meanings pywin32 was not installed by pip and that I need to install this Microsoft Visual Package: https://www.microsoft.com/en-us/download/details.aspx?id=5555. I downloaded and installed it but I'm getting the same error.

Edit:

After installing pywin32 from sourceforge.net/projects/pywin32/files/pywin32/Build%20221, the import error is gone but I'm getting warnings when it's running (the output is hundreds of lines long, here is a snippet):

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

Then I run:

pyinstaller main.spec

and get similar warnings. The resulting exe file closes immediately.


回答1:


you need to install pyinstaller and pywin32, which is same bit version as your python bit version is.

Get it from here: https://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/

choose amd64 ones if your python is 64-bit else non-amd64 ones

If you face any registry problems (or) Python installation directory not found issues, I can help



来源:https://stackoverflow.com/questions/44658534/pyinstaller-import-error-dll-load-failed-the-specified-module-could-not-be-fo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!