python - Py2Exe file closing at end, probably due to -


i made py2exe executable, it's "programming quiz". made in pygame , when run exe, works until end. assume because end has pygame text in it. error below. here's portion of code doesn't work exe normal .py:

def endgame():     global programmer     if programmer < 0:         programmer = 0     font = pygame.font.sysfont(none, 25)     text = font.render("you are: " + str(programmer) + "% programmer.", true, black)     gamedisplay.blit(text, (170,200)) 

error:

c:\python27\programming survey\dist>survey.exe survey.exe:43: runtimewarning: use font: dll load failed: specified module c ould not found. (importerror: dll load failed: specified module not found.) traceback (most recent call last):   file "survey.py", line 223, in <module>   file "survey.py", line 217, in main   file "survey.py", line 43, in endgame   file "pygame\__init__.pyc", line 70, in __getattr__ notimplementederror: font module not available (importerror: dll load failed: specified module not found.) 

ok, problem you're trying use pygame.font, installation of pygame doesn't include module.

as the docs say:

this module optional , requires sdl_ttf dependency. should test pygame.font available , initialized before attempting use module.

there 2 reasons fail load:

  1. you didn't install sdl_ttf before building pygame (or explicitly disabled it, or installed pre-compiled binary did 1 of these), support isn't built in pygame.
  2. you built against sdl_ttf dll, dll isn't available @ runtime.

either way, means can't use pygame.font.* if problem #1, need rebuild pygame (or different binary installation). if it's #2, need install sdl_ttf.dll same way installed other sdl dlls.

if you're not sure, try #2 first, and, if still doesn't work, need new build of pygame.

if know you're doing (or think maybe whoever built binary may have included support instead of pygame.font), may want consider using pygame.freetype (which has different interface) or pygame.ftfont (a complete drop-in replacement pygame.font build on pygame.freetype) instead. may want os.putenv('pygame_freetype', '1') or similar, makes newer versions of pygame.font try pygame.ftfont fallback. of more relevant linux users windows users. note it's not included in standard builds until 1.9.2, , of 5 dec 2014 they're still not shipping official releases of 1.9.2.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -