PyInstaller警告:找不到lib

时间:2018-02-09 18:39:10

标签: python pyinstaller

我知道之前已经问过这类问题,但我找不到合适的解决方案。我有一个python文件,我想在Windows 10上转换为exe。我运行pyinstaller --onefile --noconsole myfile.py,它输出很多的警告:

C:\Users\conne\Desktop\Python >pyinstaller --onefile --noconsole normal.py
277 INFO: PyInstaller: 3.3.1
277 INFO: Python: 3.6.2
278 INFO: Platform: Windows-10-10.0.15063-SP0
279 INFO: wrote C:\Users\conne\Desktop\Python\normal.spec
280 INFO: UPX is not available.
283 INFO: Extending PYTHONPATH with paths
['C:\\Users\\conne\\Desktop\\python',
 'C:\\Users\\conne\\Desktop\\python']
283 INFO: checking Analysis
284 INFO: Building Analysis because out00-Analysis.toc is non existent
284 INFO: Initializing module dependency graph...
286 INFO: Initializing module graph hooks...
289 INFO: Analyzing base_library.zip ...
5055 INFO: running Analysis out00-Analysis.toc
5058 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\conne\appdata\local\programs\python\python36\python.exe
5145 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5225 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5298 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5371 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5442 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5526 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
5598 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
5669 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
5753 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
5840 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
6061 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6134 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6208 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6282 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6354 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6430 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6503 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6576 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6651 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6725 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6798 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6879 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6882 INFO: Caching module hooks...
6892 INFO: Analyzing C:\Users\conne\Desktop\python meterpreter\normal.py
6898 INFO: Loading module hooks...
6899 INFO: Loading module hook "hook-encodings.py"...
7055 INFO: Loading module hook "hook-pydoc.py"...
7057 INFO: Loading module hook "hook-xml.py"...
7351 INFO: Looking for ctypes DLLs
7351 INFO: Analyzing run-time hooks ...
7360 INFO: Looking for dynamic libraries
7439 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7515 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7589 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7660 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7731 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7813 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7895 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7968 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
8051 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
8133 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
8213 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
8286 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
8361 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
8440 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
8512 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
8585 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
8658 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
8741 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
8815 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
8887 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
8958 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9032 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9116 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9194 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9271 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9344 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9428 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9501 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9580 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9651 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9723 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9801 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_lzma.pyd
9874 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_lzma.pyd
9959 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_socket.pyd
10030 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_socket.pyd
10115 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\select.pyd
10123 INFO: Looking for eggs
10123 INFO: Using Python library c:\users\conne\appdata\local\programs\python\python36\python36.dll
10124 INFO: Found binding redirects:
[]
10128 INFO: Warnings written to C:\Users\conne\Desktop\python\build\normal\warnnormal.txt
10196 INFO: Graph cross-reference written to C:\Users\conne\Desktop\python\build\normal\xref-normal.html
10212 INFO: checking PYZ
10212 INFO: Building PYZ because out00-PYZ.toc is non existent
10213 INFO: Building PYZ (ZlibArchive) C:\Users\conne\Desktop\python\build\normal\out00-PYZ.pyz
10948 INFO: Building PYZ (ZlibArchive) C:\Users\conne\Desktop\python\build\normal\out00-PYZ.pyz completed successfully.
10958 INFO: checking PKG
10958 INFO: Building PKG because out00-PKG.toc is non existent
10959 INFO: Building PKG (CArchive) out00-PKG.pkg
12884 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
12887 INFO: Bootloader c:\users\conne\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
12887 INFO: checking EXE
12888 INFO: Building EXE because out00-EXE.toc is non existent
12888 INFO: Building EXE from out00-EXE.toc
12916 INFO: Appending archive to EXE C:\Users\conne\Desktop\python meterpreter\dist\normal.exe
13011 INFO: Building EXE from out00-EXE.toc completed successfully.

正如您所看到的,exe已成功创建,但它在运行时无法正常工作。

编辑: 我在启用调试的情况下运行它,显然它无法导入ctypes,它会引发名称错误。它只在使用pyinstaller运行时执行此操作,当作为.py文件运行时,它可以正常工作。

9 个答案:

答案 0 :(得分:6)

我在system32 / downlevel和syswow64 / downlevel中找到了DLL,并将它们全部复制到了各自的父文件夹(system32和syswow64)。 Ritesh Singh的命令会做的事情。如果复制仍然无效,请尝试在复制后重新启动。

答案 1 :(得分:3)

  

26095警告:找不到lib:c:\ users \ user \ appdata \ local \ programs \ python \ python36-32 \ DLLs \的api-ms-win-crt-runtime-l1-1-0.dll依赖性select.pyd

在C:驱动器中搜索dll,并在pyinstaller命令中设置路径。以下命令修复了Windows 10中的上述pyinstaller错误:

pyinstaller --paths C:\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_10.0.17134.1_none_50c6cb8431e7428f hello.py

答案 2 :(得分:3)

我只是在环境变量中添加了路径,它对我有用。

C:\ Program Files(x86)\ Windows Kits \ 10 \ Redist \ ucrt \ DLLs \ x64

(或)

C:\ Program Files(x86)\ Windows Kits \ 10 \ Redist \ ucrt \ DLLs \ x86

答案 3 :(得分:1)

请注意,自2019年4月3日起,当前pyinstaller 3.5的开发版本未显示这些警告。 (3.5.dev0 + g8c27d266)

pip install git+https://github.com/pyinstaller/pyinstaller.git

答案 4 :(得分:1)

您需要根据系统体系结构安装以下Visual C ++软件包之一。


最新支持的Visual C ++下载

Visual Studio 2015、2017和2019


下载Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019。以下更新是Visual Studio 2015、2017和2019最新支持的Visual C ++可再发行组件包。其中包括Universal C Runtime的基准版本。有关详细信息,请参见MSDN

注意:Visual C ++ 2015、2017和2019共享相同的可再发行文件。

例如,安装Visual C ++ 2019可再发行组件也会影响使用Visual C ++ 2015和2017生成的程序。但是,安装Visual C ++ 2015可再发行组件将不会替换Visual C ++ 2017和2019可再发行组件所安装文件的较新版本。

这与所有以前的Visual C ++版本不同,因为它们每个都有自己的不同的运行时文件,而不与其他版本共享。

Visual Studio 2013(VC ++ 12.0)


有关更多信息,请参见C++ Runtime for Sideloaded Windows 8.1 apps上的the VC++ Team Blog

Visual Studio 2012(VC ++ 11.0)


下载Microsoft Visual C++ Redistributable Packages for Visual Studio 2012 Update 4。这是Visual Studio 2012最新支持的Visual C ++可再发行组件包。

Visual Studio 2010(VC ++ 10.0)SP1


Visual Studio 2008(VC ++ 9.0)SP1



Source

答案 5 :(得分:1)

当pyinstaller发出大量关于无法找到Windows DLL的警告时,您可以检查它们是否位于以下两个位置之一:

C:\Windows\System32\downlevel
C:\Windows\SysWOW64\downlevel

您可以将一个或两个都添加到PATH变量中,就像这样,这些警告应该消失:

set PATH=%PATH%;C:\Windows\System32\downlevel

之所以提到这一点,是因为它比查找DLL并将其复制到Alex F所提到的路径上的文件夹中要容易。我还注意到您无法找到的某些DLL位于我上面调用的文件夹中。

答案 6 :(得分:0)

出于某种原因,它在导入ctypes时抛出NameError,将此行添加到pyinstaller命令解决了问题:--hidden-import ctypes

答案 7 :(得分:0)

我遇到了这个问题,没有任何记录的pyinstaller修复操作有效。我能够通过下载DLL(我从SDK包中获取它们)并将它们复制到system32和sysWOW64来解决这个问题。所有程序现在都向后兼容了!

答案 8 :(得分:0)

请按照以下步骤解决 “ PyInstaller警告:找不到lib:api-ms-win-crt解决方案”

  1. 在命令提示符或Windows Power-shell中运行以下命令行
  2. pyinstaller --windowed --paths C:\ Windows \ System32 \ downlevel application_name.py

其他信息可以在MS网站上找到here