Pyinstaller:导入错误:DLL加载失败:找不到指定的模块

时间:2017-06-20 16:31:35

标签: python pyqt python-3.5 pyqt5 pyinstaller

我尝试从使用PyQt5的代码创建可执行文件。我使用的是Python 3.5.3 -64位,在Windows 10中开发,并使用pip来安装pyinstaller 3.2.1。

我这样运行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文件立即关闭。

1 个答案:

答案 0 :(得分:1)

你需要安装pyinstaller和pywin32,它与python位版本的位版本相同。

从这里获取:https://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/

如果你的python是64位,那么选择amd64的那些非amd64的那些

如果您遇到任何注册表问题(或)Python安装目录未找到问题,我可以提供帮助