使用pygame2exe时字体模块错误
作者:互联网
我使用了Pygame网站上的Pygame2exe,它消除了.dll的问题,但仍然存在错误.
我使用的唯一字体是标准pygame字体(freesansbold.ttf),并且我在游戏目录中包含了它的副本.
也,
我使用的是Font类,而不是SysFonts类,我认为这可以解决我的问题.
有什么想法吗?
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)
解决方法:
您的问题看起来与此非常相似:http://thadeusb.com/weblog/2009/4/15/pygame_font_and_py2exe
尝试将“ sdl_ttf.dll”添加到系统dll列表中,如下所示:
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
标签:py2exe,python,pygame 来源: https://codeday.me/bug/20191011/1889533.html