简体   繁体   中英

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". 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

The problem is most likely that you're missing DLLs on the machine that won't run the executable.

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.

From asking in the questions, it points towards a Visual C++ runtime. That can be installed either via a full set of Visual C++ suit or just a VCruntime (usually) .

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 -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) . 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/

All solutions need MS Visual C++ dll to be installed on target machine, except py2app. Only Pyinstaller makes self-executable exe that bundles the dll when passing --onefile to Configure.py.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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