py2exe gives EOFError

718 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.