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

[pygame] EXE: Narrowing Down the Problem



I've done more testing of Py2EXE and narrowed down my problem with it. I can build a working EXE using a minimal Pygame program, so long as I do nothing with the pygame.font module, ie. never loading or using a font.Font object.

It's been suggested that what an EXE using Pygame needs is to have SDL.dll and SDL_ttf.dll copied over to the dist directory, and I used to need to copy freesandbold.ttf as well. (I've also tried using arial.ttf.)

Still I get that error on running the EXE:
"pygame_\__init__.pyc", line 70, in __getattr__
NotImplementedError: font module not available
(ImportError: DLL load failed: The specified module could not be found.)

It appears that Pygame has a bug that makes it unusable if you want to build an EXE and have text displayed in it.

Is anyone else able to build a working EXE with my minimal Pygame test program, and if so, how?

Code:

## pygame_test.py
import pygame
pygame.init()
pygame.font.init() # EXE crash references this line
screen = pygame.display.set_mode((640,480))
screen.fill((0,0,128))
f = pygame.font.Font(None,24) ## Or "arial.ttf"
t = f.render("Here you can see a nice ice key which you can have for free.",1,(255,255,255))
screen.blit(t,(10,50))
screen.set_at((10,100),(255,255,0))
screen.set_at((110,100),(255,255,0))
screen.set_at((60,100),(255,255,0))
pygame.display.update()
import time
time.sleep(1.0)

## setup_py
## Command line: python setup_py py2exe
from distutils.core import setup
import py2exe
setup(console=["pygame_test.py"])