简体   繁体   English

Pyinstaller 未将 .py 转换为 .exe,因为找不到 lib

[英]Pyinstaller not converting .py to .exe because lib not found

I cannot convert a python file into an executable with pyinstaller because, when I try to convert it, the following errors are returned:我无法使用 pyinstaller 将 python 文件转换为可执行文件,因为当我尝试转换它时,会返回以下错误:

4116 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\myname\appdata\local\programs\python\python37-32\VCRUNTIME140.dll
4173 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\myname\appdata\local\programs\python\python37-32\VCRUNTIME140.dll
4394 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\users\myname\appdata\local\programs\python\python37-32\python37.dll
4465 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\myname\appdata\local\programs\python\python37-32\python37.dll
5291 WARNING: lib not found: api-ms-win-core-namedpipe-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
5312 WARNING: lib not found: api-ms-win-core-rtlsupport-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll

actually there are many more than these 4 but they are all sharing the common problem of lib not found: api-ms-win-crt实际上除了这 4 个之外还有很多,但它们都有一个共同的问题lib not found: api-ms-win-crt

The python program manages an excel file and then generates an email through outlook. python程序管理一个excel文件,然后通过outlook生成邮件。 Packages used by the program are Tkinter, Openpyxl and win32com.client, but only the last one is (I think) the one giving problems.该程序使用的软件包是 Tkinter、Openpyxl 和 win32com.client,但只有最后一个是(我认为)出现问题的一个。 What can I do to convert it properly?我该怎么做才能正确转换它? Thank you for your help感谢您的帮助

If you are creating the exe on win 10 then those library's don't really matter because of the way win 10 works.如果您在 win 10 上创建 exe,那么这些库并不重要,因为 win 10 的工作方式。 If you create it on win 10 though you won't be able to use it on Win 7 without those DLL's.如果您在 win 10 上创建它,但如果没有这些 DLL,您将无法在 Win 7 上使用它。

If you want the DLL's for it to work on win 7 then you need to copy the DLLs from microsoft runtime visual c++ 2015 into the python DLL folder usually located at C:\\Users\\"user"\\AppData\\Local\\Programs\\Python\\Python36\\DLLs .如果您希望 DLL 在 win 7 上运行,那么您需要将 DLL 从 microsoft runtime visual c++ 2015 复制到通常位于C:\\Users\\"user"\\AppData\\Local\\Programs\\Python\\Python36\\DLLs的 python DLL 文件夹中C:\\Users\\"user"\\AppData\\Local\\Programs\\Python\\Python36\\DLLs

To properly create the exe all you need to do is hold Shift, right click within the folder where your .py is and open a CMD window within this folder.要正确创建 exe,您需要做的就是按住 Shift,在 .py 所在的文件夹中右键单击,然后在该文件夹中打开一个 CMD 窗口。 Run this command with your .py name.使用您的 .py 名称运行此命令。

pyinstaller --clean --noconsole -F "".py

You should get a few folders and your exe will be located in the dist folder.你应该得到一些文件夹,你的 exe 将位于 dist 文件夹中。

Let me know if you have any questions.如果您有任何问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM