raw_input causing EOFError after creating exe with py2exe

前端 未结 1 611
萌比男神i
萌比男神i 2021-01-05 16:00

After creating an exe from a script with py2exe raw_input() is causing an EOFError.

How can I avoid this?

 File \"test.py\"         


        
1条回答
  •  南笙
    南笙 (楼主)
    2021-01-05 16:34

    >>> help(raw_input)
    Help on built-in function raw_input in module __builtin__:
    
    raw_input(...)
        raw_input([prompt]) -> string
    
        Read a string from standard input.  The trailing newline is stripped.
        If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
        On Unix, GNU readline is used if enabled.  The prompt string, if given,
        is printed without a trailing newline before reading.
    

    what's wrong? what do you type on the keyboard?

    edit (reported comment up here):

    My guess is that you used py2exe with the "windows" argument, meaning that no console is opened - without a console there is no stdin for raw_input to use. You can instead use the "console" argument in your setup.py, and your exe will open a console window allowing raw_input to work

    0 讨论(0)
提交回复
热议问题