Python 冻结的可执行文件在某些​​计算机上无法运行

Python Frozen Executable Files are not Working on Some Computers

我冻结的 Python 文件在我的计算机上正常运行。我用 cx_freeze 冻结了它们,但在某些计算机上它们不起作用。例如在Windows 7 中,它总是需要DLL 文件,它说它们丢失了。通常是关于api-ms-win个DLL文件。

在Windows10中,显示这个错误:

但在我的电脑上,它工作正常。这怎么可能,我该如何解决?

有很多潜在的问题,但最常见的 Python 3.5+ 和 Windows 10 似乎缺少 api-ms-win dll。

为了帮助我的 Python 冻结程序找到所需的 DLL:

这是 pyinstaller 问题跟踪器中的一组注释:

Add the directory of the required dlls to system Path. My application uses PyQt5 which is dependent on api-ms-win dlls.

For PyQt5 add this directory:

%WHERE EVER YOU INSTALLED PYTHON%\Lib\site-packages\PyQt5\Qt\bin

For api-ms-win dlls you need Visual Studio 2015 OR Windows SDK (download here): Directory if you have Visual Studio: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64 Directory if you have Windows SDK: C:\Program Files (x86)\Windows Kits\Redist\ucrt\DLLs\x64

添加所需路径后,pyinstaller 可以找到文件。

(SOURCE)

但是缺少什么 DLL?

太有助于找到任何丢失的 DLL,您可以使用 Dependency Walker 找到您的程序需要的所有 DLL。

我应该改用 Pyinstaller 吗?

如果您使用的冻结实用程序不合作,通常值得尝试其他一些冻结实用程序。