【问题标题】:Cx_freeze error lost sys.stdinCx_freeze 错误丢失 sys.stdin
【发布时间】:2013-04-23 19:37:56
【问题描述】:

这是一个困扰我一段时间的问题。我已经查过了,但没有找到答案。我也尝试过自己弄清楚,但没有成功。每当我创建并尝试冻结其中包含 input() 函数的程序时,我都会遇到相同的错误。

我尝试在命令提示符下运行.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


    【解决方案1】:

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

    如果你想创建一个控制台程序,设置base='Console'(或base=None,因为Console是默认的)。

    【讨论】:

    • 我应该在哪里添加“base='console'”关键字,使其在控制台中运行?
    猜你喜欢
    • 2013-11-17
    • 2016-08-28
    • 2020-02-19
    • 2011-12-02
    • 1970-01-01
    • 1970-01-01
    • 2011-04-22
    • 2019-01-10
    • 1970-01-01
    相关资源
    最近更新 更多