2

I have a simple program, I used pygame to import sound but it is still a CLI program. Whenever I compile it into an exe it gives me an EOFError when I try to run it, It looks like this

Traceback (most recent call last):
  File "PlanetaryDistanceFromSun.pyw", line 57, in <module>
  File "PlanetaryDistanceFromSun.pyw", line 31, in main
  File "PlanetaryDistanceFromSun.pyw", line 44, in Planet
EOFError: EOF when reading a line

Here is the piece of code in question: raw_input("How far is %s from the sun? " % planet)

I did a fair amount of searching on the internet and found a few things that said I need a console argument, but I don't understand what that is.

WillumMaguire
  • 537
  • 2
  • 10
  • 21
  • What do you mean "I can't post properly written the code because of the formatting this the site uses"? Formatting inside code blocks is preserved verbatim. – Wug Aug 14 '12 at 19:21
  • My fault, I'm new here and didn't know how that worked, I'll fix it – WillumMaguire Aug 14 '12 at 19:24
  • Duplicate of: http://stackoverflow.com/questions/4280889/raw-input-causing-eoferror-after-creating-exe-with-py2exe? – hifkanotiks Aug 14 '12 at 20:07

1 Answers1

0

Have a look at this py2exe example from the pygame website:

It also contains the solution to your problem:

This will only work for GUI apps, change "windows =" to "console =" in setup command would do the job.

The relevant part is this (IIRC):

...
windows = [{
            'script': self.script,
            'icon_resources': [(0, self.icon_file)],
            'copyright': self.copyright
        }],
...

where you have to change windows to console.

Also, this thread on the pygame-user mailing list describes the same issue:

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.

sloth
  • 99,095
  • 21
  • 171
  • 219