我在Python中创建了一个应用程序,并使用cx_Freeze
使其可执行。
当脚本未转换为可执行文件时,它用于从cmd
(在Windows中)获取输入。但是,当它转换为exe时,它不会提示我输入。
我已将以下代码用作setup.py
作为我的脚本。
includefiles = ["checkPointValueSheets.py"] # include any files here that you wish
includes = []
excludes = []
packages = ["lxml"]
exe = Executable(
# what to build
script = "app.py", # the name of your main python script goes here
initScript = None,
base = None, # if creating a GUI instead of a console app, type "Win32GUI"
targetName = "aflPredictionAutomation.exe", # this is the name of the executable file
copyDependentFiles = True,
compress = True,
appendScriptToExe = True,
appendScriptToLibrary = True,
icon = None # if you want to use an icon file, specify the file name here
)
setup(
# the actual setup & the definition of other misc. info
name = "app", # program name
version = "0.1",
description = 'A general enhancement utility',
author = "K Perkins",
author_email = "",
options = {"build_exe": {"excludes":excludes,"packages":packages,
"include_files":includefiles}},
executables = [exe]
)
请在我输入exe文件时帮助我启动cmd控制台。
运行可执行文件时出现此错误..
由于
答案 0 :(得分:2)
已经在您的代码的评论中(并且在cx_Freeze’s documentation中,您应该只评论2行
if sys.platform == "win32":
base = "Win32GUI"
如果你让base = None
你的exe将是一个控制台应用程序(而不是一个GUI),Windows将自动为它提供一个新的控制台,如果还没有从一个启动器。