Python PyInstaller 警告:找不到 lib

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48712154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:49:32  来源:igfitidea点击:

PyInstaller WARNING: lib not found

pythonpyinstaller

提问by Conner Dassen

I know this type of question has been asked here before, but I did not find a working solution to it. I have a python file which I want to convert to an exe on Windows 10. I ran pyinstaller --onefile --noconsole myfile.py, and it outputted a lotof warnings:

我知道以前有人在这里问过这种类型的问题,但我没有找到可行的解决方案。我有一个 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.

As you can see the exe is created successfully, but it doesn't work as it should when running it.

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

EDIT: I ran it with debug enabled and apparently it can't import ctypes, it throws a name error. It only does this when running with pyinstaller, when running as a .py file it works fine.

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

采纳答案by Conner Dassen

For some reason it threw a NameErrorwhen importing ctypes, adding this line to the pyinstaller command solved the issue: --hidden-import ctypes

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

回答by SajanGohil

I found the DLL's in system32/downlevel and syswow64/downlevel and copied all of them to the respective parent folders (system32 and syswow64). Something that Ritesh Singh's command will do. Try a restart after copying if it still does not work.

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

回答by Crazy Lazy

I just added the path in the environmental variable, it worked for me.

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

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

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

(or)

(或者)

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

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

回答by Ritesh Singh

26095 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\user\appdata\local\programs\python\python36-32\DLLs\select.pyd

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

Search in C: drive for dll and set the path in pyinstaller command. The below command fixed the above pyinstaller error in windows 10:

在 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

回答by David Rueter

Note that as of 4/3/2019 the current dev version of pyinstaller 3.5 does not show these warnings. (3.5.dev0+g8c27d266)

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

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

回答by CONvid19

You'll need to install one of the Visual C++ packages bellow according to your system architecture.

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



The latest supported Visual C++ downloads

最新支持的 Visual C++ 下载

Visual Studio 2015, 2017 and 2019

Visual Studio 2015、2017 和 2019



Download the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019. The following updates are the latest supported Visual C++ redistributable packages for Visual Studio 2015, 2017 and 2019. Included is a baseline version of the Universal C Runtime see MSDNfor details.

下载适用于 Visual Studio 2015、2017 和 2019Microsoft Visual C++ Redistributable。以下更新是适用于 Visual Studio 2015、2017 和 2019 的最新受支持的 Visual C++ 可再发行组件包。包括通用 C 运行时的基线版本,有关详细信息,请参阅MSDN

NoteVisual C++ 2015, 2017 and 2019 all share the same redistributable files.

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

For example, installing the Visual C++ 2019 redistributable will affect programs built with Visual C++ 2015 and 2017 also. However, installing the Visual C++ 2015 redistributable will not replace the newer versions of the files installed by the Visual C++ 2017 and 2019 redistributables.

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

This is different from all previous Visual C++ versions, as they each had their own distinct runtime files, not shared with other versions.

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

Visual Studio 2013 (VC++ 12.0)

Visual Studio 2013 (VC++ 12.0)



For more information, see C++ Runtime for Sideloaded Windows 8.1 appson the VC++ Team Blog.

有关详细信息,请参阅VC++ 团队博客旁加载 Windows 8.1 应用程序的 C++ 运行时

Visual Studio 2012 (VC++ 11.0)

Visual Studio 2012 (VC++ 11.0)



Download the Microsoft Visual C++ Redistributable Packages for Visual Studio 2012 Update 4. This is the latest supported Visual C++ redistributable package for Visual Studio 2012.

下载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 2010 (VC++ 10.0) SP1



Visual Studio 2008 (VC++ 9.0) SP1

Visual Studio 2008 (VC++ 9.0) SP1





Source

来源

回答by rkengler

When there is a whole slew of WARNINGS coming from pyinstaller about not being able to locate Windows DLLs, you might check to see if they're in one of the two following locations:

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

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

You can add one or both to the PATH variable, like so and those warnings should disappear:

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

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

I mention this because it's easier than finding and copying the DLLs to a folder on the path like Alex F mentioned. I also noticed some of the DLLs you're unable to locate are in the folders I called out above.

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

回答by Alex F

I ran into this issue and none of the documented pyinstaller fix actions worked. I was able to resolve this by downloading the DLLs (I got them from the SDK package) and copying them into system32 and sysWOW64. All programs are now backwards compatible!

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

回答by Mahama Abdul - Hakim

Follow the next steps to solve the "PyInstaller WARNING:lib not found:api-ms-win-crt SOLUTION"problem:

按照以下步骤解决“PyInstaller WARNING:lib not found:api-ms-win-crt SOLUTION”问题:

  1. run the following command line in command prompt or windows power-shell
  2. pyinstaller --windowed --paths C:\Windows\System32\downlevel application_name.py
  1. 在命令提示符或 windows power-shell 中运行以下命令行
  2. pyinstaller --windowed --paths C:\Windows\System32\downlevel application_name.py

Additional information can be found hereat the MS website.

更多信息可以发现这里在MS的网站。