[英]pyinstaller exe created on Windows 8 does not work in Windows 7
I've made an executable file in Windows 8. It runs properly in Windows 8 and 10. The problem is when I double click the exe file in Windows 7 I get the message "myfile.exe has stopped working". 我已经在Windows 8中制作了一个可执行文件。它可以在Windows 8和10中正常运行。问题是,当我双击Windows 7中的exe文件时,出现消息“ myfile.exe已停止工作”。 I tested all things which come to my mind but the problems still remains.
我测试了所有想到的东西,但问题仍然存在。
The figure below is the message when I run my exe file 下图是我运行exe文件时的消息
The problem is most likely that you're missing DLLs on the machine that won't run the executable. 问题很可能是您在无法运行可执行文件的计算机上丢失了DLL。
This is due to the fact that some where, some time you've installed either a .NET environment, a Visual XXX environment or a runtime containing a particular set of DDL's for the application to function. 这是由于以下事实:在某些位置,一段时间内,您已经安装了.NET环境,Visual XXX环境或包含特定DDL集的运行时,以使应用程序正常运行。
From asking in the questions, it points towards a Visual C++ runtime. 从提出问题开始,它指向Visual C ++运行时。 That can be installed either via a full set of Visual C++ suit or just a VCruntime (usually) .
可以安装或者通过全套的Visual C ++的诉讼或只是一个VCruntime(通常)。
It's also important to point out that these runtimes come with their own terms of agreements and licenses. 同样重要的是要指出这些运行时带有它们自己的协议和许可条款。 That's why they aren't packed in the executable (also, usually) .
这就是为什么它们不打包在可执行文件中的原因(通常也是) 。 You can bundle them in your executable, depending on which freeze technique you use, but it's not allowed and you need to have permission to do so.
您可以将它们捆绑在可执行文件中,具体取决于您使用的冻结技术,但这是不允许的,并且您需要具有这样做的权限。
One way of doing it (via pyinstaller) is doing: 一种实现方式(通过pyinstaller)是:
pyinstaller -F --add-data ucrtbase.dll;. myscript.py
Again, check with the license if this is allowed. 再次,检查许可证是否允许。
If you against all odds decide to copy and paste the DLL with your .exe, you need to make sure it's accessible via your Windows PATH
environment, seeing as that's where your executable will look for the DLLs (usually system32 or other paths) . 如果千方百计决定使用.exe复制并粘贴DLL,则需要确保可通过Windows
PATH
环境访问该DLL,因为这是您的可执行文件在其中寻找DLL (通常是system32或其他路径)的地方 。 So blindly copying it because someone on the internet said so, doesn't always work. 因此,一味地复制它是因为互联网上的某人这样说并不总是可行。 You have to learn and understand why it would work and how it works.
您必须学习并理解它为什么会工作以及如何工作。
Here's a good external source that describes this phenomena pretty well: https://docs.python-guide.org/shipping/freezing/ 这是一个很好的外部资源,很好地描述了这种现象: https : //docs.python-guide.org/shipping/freezing/
All solutions need MS Visual C++ dll to be installed on target machine, except py2app.
除py2app之外,所有解决方案都需要在目标计算机上安装MS Visual C ++ dll。 Only Pyinstaller makes self-executable exe that bundles the dll when passing --onefile to Configure.py.
只有Pyinstaller可以将--onefile传递给Configure.py时,将dll捆绑在一起的可自行执行的exe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.