python-3.xcx-freeze

Cx_freeze error lost sys.stdin


This is a problem that has been bothering me for a while. I have looked it up, but found no answer. I have also tried figuring it out myself, but have not succeeded. Whenever I create and try to freeze a program with the input() function in it I get the same error. enter image description here

I have tried running the .exe in command prompt but I get the same error. My setup.py script is below.

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]
     )

And my short test script:

import sys,re
input('input')

Is this a problem I can fix, or do I just have to work without the input() function? I am using Python 3.2, on windows seven, with the corresponding cx_freeze version. Thanks in advance.


Solution

  • The Win32GUI base is designed for Windows GUI programs - i.e. they run in windows, not at a command prompt. So there's no stdin, and you can't use input().

    If you want to create a console program, set base='Console' (or base=None, since Console is the default).