Python 到 EXE 构建一个空文件

Python to EXE builds a nothing-doing file

我使用 cx_Freeze 模块将我的 Python 应用程序转换为 Windows。

我有一个简单的 Python 文件 norm.py :

print("Hi there !")

另一个文件makeup.py将上面的转换成exe:

import sys
from cx_Freeze import setup, Executable

include_files = ['autorun.inf']
os_base = None

if sys.platform == "win32":
    os_base = "Win32GUI"

setup(name="puzzle",
        version="0.1",
        description="Very cool puzzle",
        options={'build_exe':{'include_files':include_files}},
        executables=[Executable("norm.py", base=os_base)])

我在同一文件夹中也有 autorun.inf。 当我通过 运行ning 命令构建它时也没有出现错误:

python makeup.py build

它创建了一个 build 文件夹,里面有 norm.exe。当我通过我的终端 运行 这个 exe 时,它​​不执行 anything.I 我期待它打印 "Hi there!"

我正在使用 Python 3.4,因为有些帖子说 3.5 这个模块有问题。

您正在使用

创建 GUI 应用程序
if sys.platform == "win32":
    os_base = "Win32GUI"

您应该删除它,以便构建控制台应用程序。

如果您没有任何错误,可能是您必须在 "print("下方写下 "input()" 您好!")"。

print ("Hi there !")
input()