#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    4
    Rep Power
    0

    EOF error with raw_input from a exe / text color


    I have got py2.exe and have made a exe of a game, but everytime I run the exe it brings up a EOF error on the raw_input line
    cmd = raw_input("> ")

    This runs fine in the IDLE but not as a exe.
    got any ideas?
    Also how do you change the text color through the programming. foreground and background color if possible.
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Just a guess but ...
    Did you compile that application as a console application or a windows application? I would expect it needs to be a console app.

    If you still having problems, try posting your setup script and a log from py2exe.

    You can change the whole console with this:
    Code:
    import os
    os.system("color E0")
    Where E0 is a hex value corresponding to background/foreground colours:
    Code:
    0 	Black 	8 	Gray
    1 	Blue 	9 	Light Blue
    2 	Green 	A 	Light Green
    3 	Aqua 	B 	Light Aqua
    4 	Red 	C 	Light Red
    5 	Purple 	D 	Light Purple
    6 	Yellow 	E 	Light Yellow
    7 	White 	F 	Bright White
    If you need more control then the following module is supposed (I haven't used it myself) to allow individual character colouration:
    WConio

    Have fun

    grim
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    4
    Rep Power
    0

    thanks but...


    maybe I should have told ya first that I have only been using python for the past three days. And what you are saying doesn't make much sense( i don't know what a console is) heres my setup.py I think..
    Code:
    # A setup script showing advanced features.
    #
    # Note that for the NT service to build correctly, you need at least
    # win32all build 161, for the COM samples, you need build 163.
    # Requires wxPython, and Tim Golden's WMI module.
    
    from distutils.core import setup
    import py2exe
    import sys
    
    # If run without args, build executables, in quiet mode.
    if len(sys.argv) == 1:
        sys.argv.append("py2exe")
        sys.argv.append("-q")
    
    class Target:
        def __init__(self, **kw):
            self.__dict__.update(kw)
            # for the versioninfo resources
            self.version = "0.5.0"
            self.company_name = "No Company"
            self.copyright = "no copyright"
            self.name = "py2exe sample files"
    
    ################################################################
    # A program using wxPython
    
    # The manifest will be inserted as resource into test_wx.exe.  This
    # gives the controls the Windows XP appearance (if run on XP ;-)
    #
    # Another option would be to store it in a file named
    # test_wx.exe.manifest, and copy it with the data_files option into
    # the dist-dir.
    #
    manifest_template = '''
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity
        version="5.0.0.0"
        processorArchitecture="x86"
        name="%(prog)s"
        type="win32"
    />
    <description>%(prog)s Program</description>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="X86"
                publicKeyToken="6595b64144ccf1df"
                language="*"
            />
        </dependentAssembly>
    </dependency>
    </assembly>
    '''
    
    RT_MANIFEST = 24
    
    test_wx = Target(
        # used for the versioninfo resource
        description = "A sample GUI app",
    
        # what to build
        script = "test_wx.py",
        other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog="test_wx"))],
    ##    icon_resources = [(1, "icon.ico")],
        dest_base = "test_wx")
    
    test_wx_console = Target(
        # used for the versioninfo resource
        description = "A sample GUI app with console",
    
        # what to build
        script = "test_wx.py",
        other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog="test_wx"))],
        dest_base = "test_wx_console")
    
    ################################################################
    # A program using early bound COM, needs the typelibs option below
    test_wmi = Target(
        description = "Early bound COM client example",
        script = "test_wmi.py",
        )
    
    ################################################################
    # a NT service, modules is required
    myservice = Target(
        # used for the versioninfo resource
        description = "A sample Windows NT service",
        # what to build.  For a service, the module name (not the
        # filename) must be specified!
        modules = ["MyService"]
        )
    
    ################################################################
    # a COM server (exe and dll), modules is required
    #
    # If you only want a dll or an exe, comment out one of the create_xxx
    # lines below.
    
    interp = Target(
        description = "Python Interpreter as COM server module",
        # what to build.  For COM servers, the module name (not the
        # filename) must be specified!
        modules = ["win32com.servers.interp"],
    ##    create_exe = False,
    ##    create_dll = False,
        )
    
    ################################################################
    # COM pulls in a lot of stuff which we don't want or need.
    
    excludes = ["pywin", "pywin.debugger", "pywin.debugger.dbgcon",
                "pywin.dialogs", "pywin.dialogs.list"]
    
    setup(
        options = {"py2exe": {"typelibs":
                              # typelib for WMI
                              [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)],
                              # create a compressed zip archive
                              "compressed": 1,
                              "optimize": 2,
                              "excludes": excludes}},
        # The lib directory contains everything except the executables and the python dll.
        # Can include a subdirectory name.
        zipfile = "lib/shared.zip",
    
        service = [myservice],
        com_server = [interp],
        console = [test_wx_console, test_wmi],
        windows = [test_wx],
        )
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    4
    Rep Power
    0

    the rest


    heres the log for py2

    Code:
    *** Installation started 2004/09/28 20:38 ***
    Source: C:\PYTHON23\PY2EXE-0.5.3.WIN32-PY2.3.EXE
    999 Root Key: HKEY_LOCAL_MACHINE
    020 Reg DB Key: [Software\Microsoft\Windows\CurrentVersion\Uninstall]py2exe-py2.3
    040 Reg DB Value: [Software\Microsoft\Windows\CurrentVersion\Uninstall\py2exe-py2.3]DisplayName=Python 2.3 py2exe-0.5.3
    040 Reg DB Value: [Software\Microsoft\Windows\CurrentVersion\Uninstall\py2exe-py2.3]UninstallString="C:\PYTHON23\Removepy2exe.exe" -u "C:\PYTHON23\py2exe-wininst.log"
    100 Made Dir: C:\PYTHON23\Lib\site-packages\py2exe
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_common.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_com_servers.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_service.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\build_exe.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\py2exe_util.pyd
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\run.exe
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\run_dll.dll
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\run_w.exe
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\__init__.py
    100 Made Dir: C:\PYTHON23\Lib\site-packages\py2exe\resources
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\StringTables.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\VersionInfo.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\__init__.py
    100 Made Dir: C:\PYTHON23\Lib\site-packages\py2exe\samples
    100 Made Dir: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\MyService.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\setup.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\test_wmi.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\test_wx.py
    100 Made Dir: C:\PYTHON23\Lib\site-packages\py2exe\samples\extending
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\extending\setup.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\extending\test_wx.py
    100 Made Dir: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\hello.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\setup.py
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\test_wx.py
    100 Made Dir: C:\PYTHON23\Scripts
    200 File Copy: C:\PYTHON23\Scripts\py2exe_postinstall.py
    200 File Copy: C:\PYTHON23\Scripts\py2exe_postinstall.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\test_wx.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\setup.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\hello.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\extending\test_wx.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\extending\setup.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\test_wx.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\test_wmi.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\setup.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\MyService.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\__init__.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\VersionInfo.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\StringTables.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\__init__.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\build_exe.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_service.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_com_servers.pyc
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_common.pyc
    200 File Copy: C:\PYTHON23\Scripts\py2exe_postinstall.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\test_wx.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\setup.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\simple\hello.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\extending\test_wx.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\extending\setup.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\test_wx.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\test_wmi.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\setup.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\samples\advanced\MyService.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\__init__.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\VersionInfo.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\resources\StringTables.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\__init__.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\build_exe.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_service.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_com_servers.pyo
    200 File Copy: C:\PYTHON23\Lib\site-packages\py2exe\boot_common.pyo
    300 Run Script: [python23.dll]C:\PYTHON23\Scripts\py2exe_postinstall.py
    *** Installation finished 2004/09/28 20:38 ***
    Also I don't know how to use the WConio thingy or the color. I thats what you were talking about.
  8. #5
  9. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Hi Nixon,

    The log was very helpful:
    You will find in the dist sub-directory three executable files:
    1. test_wx.exe - a pure Windows GUI application without a console
    2. test_wx_console.exe - the same GUI application but with a console.
    3. test_wmi.exe - a COM client example

    These three programs are produced from the one setup script.

    To work properly your raw_input modification requires a console to get user input- therefore to run without error you must execute test_wx_console.exe.

    A console as far as Python is concerned is an environment that provides access to the Standard input called stdin (e.g. keyboard input for raw_input ) and Standard output stdout (for the print command). [There is also Standard error (stderr)which is used for printing error messages.] Normally this means you see the Command Console or DOS box appear on your display.

    Running any python file like this:
    python myprog.py
    runs a program with a console.
    If you rename the program by putting a w at the end of the file extension the same program will be run without a console:
    python myprog.pyw
    runs a program without a console.

    BTW IDLE will run the program without a problem because IDLE is the console in that situation.

    I know it is tempting to dive right in but I really think you should forget py2exe until you have at least spent a few more days learning Python. You don't need it to run programs and you only need to worry about py2exe some time near the end of a project when you are ready to give the program to someone else.


    Have fun.

    grim
    Last edited by Grim Archon; September 30th, 2004 at 04:52 AM.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    4
    Rep Power
    0

    Thanks


    Thanks alot dude, you have been a great help. I only stumbled on this great language by acciedent cause I have to learn it for school, at first I thought it was horible but now I have spent the last 4 days programming with it. I have to get all the files I downloaded back cause I had to set my computer back 4 days due to viruses and stuff. Once I get back from blackstump then I'll try out what ya said. Also do you know where I can get text adventures for python if not where can I get games.
  12. #7
  13. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13

    A quick search threw up these:
    Interactive Fiction engines which might be what you need.

    A lot of people use this for arcade style games:
    PyGame

    If you find a good one let us know.

    grim

IMN logo majestic logo threadwatch logo seochat tools logo