Cx_freeze 错误丢失 sys.stdin

问题描述 投票:0回答:2

这是困扰我一段时间的问题。我查了一下,但没有找到答案。我自己也尝试过解决,但没有成功。每当我创建并尝试冻结带有

input()
函数的程序时,我都会遇到同样的错误。 enter image description here

我尝试在命令提示符下运行

.exe
但出现相同的错误。我的
setup.py
脚本如下。

import cx_Freeze, sys
from cx_Freeze import setup, Executable

exe=Executable(
     script="input.py",
     base="Win32Gui",

     )
includefiles=[]
includes=["re"]
excludes=[]
packages=[]
setup(

     version = "0",
     description = "No Description",
     author = "Anthony",
     name = "0",
     options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}},
     executables = [exe]
     )

我的简短测试脚本:

import sys,re
input('input')

这是我可以解决的问题,还是我必须在没有

input()
功能的情况下工作?我在 Windows 7 上使用 Python 3.2,以及相应的 cx_freeze 版本。 预先感谢。

python-3.x cx-freeze
2个回答
18
投票

Win32GUI
基础是为Windows GUI程序设计的 - 即它们在Windows中运行,而不是在命令提示符下运行。所以没有标准输入,你不能使用
input()

如果要创建控制台程序,请设置

base='Console'
(或
base=None
,因为 Console 是默认设置)。


0
投票

您可以通过在 build_exe_options 中排除“abc”来使用控制台 -


build_exe_options = {
"excludes": ["tkinter", "unittest", "abc"],
"includes": [ ],
"include_files": [ ],
"zip_include_packages": ["encodings", "PySide6"]

}

© www.soinside.com 2019 - 2024. All rights reserved.