[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame2exe



I just struggled with this one myself, literally barely 48 hours ago,
and I finally got a solution.

First, to fix your problem, take a look at this thread:
http://www.daniweb.com/forums/thread190638.html

Now, using that script instead got me further than the error you're
describing.

Next, I had to get over this bump;
When I ran py2exe, it didn't necessarily package or inform me of the
need for a handful of .DLLs.  That was the easy part, I just found
them and put them in the dist folder.  They were libogg.dll and
libtff.dll in my case.  Note that when I made frozen binaries that
didn't use ttf fonts or audio, I didn't have to deal with it.

Next I got some error about a failure to initialize "mixer_music".  I
read a lot of discussion on how to fix this, but most people's ideas
didn't work for me.  Someone finally said to roll back to Python 2.5,
and the version of Pygame for it.  That fixed that problem.  Not sure
if there's a better way, or really why that was a fix, but it worked.
Maybe research more before you try that if you don't wanna roll back?
Or more likely, your program doesn't use audio and there won't be
calls to this.

Lastly, apparently some machines are unhappy about the encoding of
text that exists in the binary.  I only have a vague idea about what
this means, but I got this tip.  Change the script like so,

setup(
  options = {"py2exe": {"compressed": 1,
                        "optimize": 2,
                        "ascii": 1,
                        "bundle_files": 1,
			"packages": ["encodings"]}},
  # replace 'DateTime1.py' with your own code filename
  # (replace console with windows for a windows program)
  console = [{"script": 'main.py'}]
)

note the added line about "packages": ["encodings"]}},

Now I'm a total newbie, but I got my game running and distributed to a
few pals to test, so I got past these hurdles.  I hope doing the same
will get your binaries running, but keep in mind I just tracked down
the tips and tricks of smarter folk who knew what they were doing.
Maybe someone who can clearly explain why all of this is the way it is
can step in or write up a singular definitive guide on distribution of
Pygame projects in windows?

I hope this helps and you spend less time than I had to figuring this all out.

-Matthew


On Sat, Oct 23, 2010 at 11:01 PM, Christopher Night
<cosmologicon@xxxxxxxxx> wrote:
> I'm completely unfamiliar with Windows, and I'm finding it so much harder to
> use than Linux. I feel like a complete idiot trying to compile something to
> exe. I did manage to get a Hello World script compiled okay, but I can't get
> a simple test pygame script to compile. I used the pygame2exe script here:
> http://www.pygame.org/wiki/Pygame2exe
> I put it in a directory with my test script test.py, changed the stuff in
> BuildExe.__init__, and ran it in IDLE. It seemed to work for a while, but
> eventually died with this traceback:
> *** finding dlls needed ***
> *** create binaries ***
> *** byte compile python files ***
> writing byte-compilation script
> 'c:\users\christ~1\appdata\local\temp\tmplkizod.py'
> C:\Python26\pythonw.exe -OO
> c:\users\christ~1\appdata\local\temp\tmplkizod.py
> Traceback (most recent call last):
>   File "C:/Users/christopher/Desktop/pygame-test/pygame2exe.py", line 155,
> in <module>
>     BuildExe().run() #Run generation
>   File "C:/Users/christopher/Desktop/pygame-test/pygame2exe.py", line 146,
> in run
>     dist_dir = self.dist_dir
>   File "C:\Python26\lib\distutils\core.py", line 169, in setup
>     raise SystemExit, "error: " + str(msg)
> SystemExit: error: command 'C:\Python26\pythonw.exe' failed with exit status
> 1
> Am I even on the right track? Is py2exe the best tool to use for compiling
> pygame-based programs, and if so, is this the right script to use? If so,
> what's with the error I'm getting? I'm hopeless debugging anything in
> Windows. When I try running that line (C:\Python26\pythonw.exe -OO
> c:\users\christ~1\appdata\local\temp\tmplkizod.py), it just exits without
> any output, leaving me with no clue what the problem is. Any advice at all
> would be much appreciated.
> Thanks!
> Christopher