Windows .exe 使用 cx_Freeze returns 0xc000007b 错误创建

Windows .exe created with cx_Freeze returns 0xc000007b error

我创建了一个小脚本来测试cx_Freeze,如下所示:

sqrt.py:

import math
sqrt = math.sqrt
x = float(input('Enter a number:'))
y = sqrt(x)
print(y)
input('Press ENTER to exit')

我还创建了一个安装脚本:

setup.py:

from cx_Freeze import setup, Executable

setup(  name = "sqrt",
        version = "0.1",
        description = "Testing",
        # options = {"build_exe": build_exe_options},
        executables = [Executable("sqrt.py")])

接下来,我在 python.exe、sqrt.py 和 setup.py 所在的文件夹中启动 Windows cmd.exe 并输入:

path\python.exe setup.py build

这会创建一个构建目录,其中包含一个 sqrt.exe。当我尝试执行此操作时,它 returns

"The application was unable to start correctly (0xc000007b). Click OK to close the application."

就我对 cx_Freeze 文档的理解而言,这应该可行。我看过的各种 YouTube 教程也是如此。

我是 运行 Windows10 64x,Python 3.5 和 cx_freeze 5.0。

您可以使用dependencywalker加载用cx_freeze创建的exe文件。

它会告诉你哪里出了问题。

也许您缺少像 Microsoft Visual C++ Redistributable Package 这样的库,或者您混合了 32 位和 64 位架构。

该工具会显示错误。

更新:我在 windows 上尝试获取 gtk 运行 时遇到了这个问题。有什么奇怪的事情。我从 gtk 切换到 pyside2 (QT),现在事情变得容易多了。