Font module error when using pygame2exe

只愿长相守 提交于 2019-12-20 02:39:20

问题


I used Pygame2exe from the Pygame website and that got rid of the problem with the .dlls but there's still an error that remains.
The only font I'm using is the standard pygame font (freesansbold.ttf) and I've included a copy of it in my game directory.
Also,
I'm using the Font class and not the SysFonts class which I thought would fix my problem.
Any thoughts?

C:\Python26\apple_orchard\dist\appleorchard.exe:27: RuntimeWarning: use font: MemoryLoadLibrary failed loading pygame\font.pyd
(ImportError: MemoryLoadLibrary failed loading pygame\font.pyd)
Traceback (most recent call last):
  File "appleorchard.py", line 165, in <module>
  File "appleorchard.py", line 27, in __init__
  File "pygame\__init__.pyo", line 70, in __getattr__
NotImplementedError: font module not available
(ImportError: MemoryLoadLibrary failed loading pygame\font.pyd)

回答1:


Your problem looks like very similar to this one : http://thadeusb.com/weblog/2009/4/15/pygame_font_and_py2exe

Try to add "sdl_ttf.dll" to the list of system dlls like this :

origIsSystemDLL = py2exe.build_exe.isSystemDLL # save the orginal before we edit it
def isSystemDLL(pathname):
    # checks if the freetype and ogg dll files are being included
    if os.path.basename(pathname).lower() in ("libfreetype-6.dll", "libogg-0.dll", "sdl_ttf.dll"):
            return 0
    return origIsSystemDLL(pathname) # return the orginal function
py2exe.build_exe.isSystemDLL = isSystemDLL # override the default function with this one



回答2:


Looks like the pygame.font module is missing. Did you pack it?



来源:https://stackoverflow.com/questions/6376194/font-module-error-when-using-pygame2exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!