py2ex之后Pygame字体不起作用

2024-10-03 04:32:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这样的代码,当我用py2exe将它转换为.exe时,它可以正常工作,除非它试图在屏幕上加载文本。它会出现一个错误:

C:\Users\Slinky\Desktop\dist\FlappyBat.exe:120: RuntimeWarning: use font: DLL load failed:                   The specified module could not be found.
(ImportError: DLL load failed: The specified module could not be found.)
Traceback (most recent call last):
File "FlappyBat.py", line 176, in <module>
File "FlappyBat.py", line 120, in main
File "pygame\__init__.pyc", line 70, in __getattr__
NotImplementedError: font module not available
(ImportError: DLL load failed: The specified module could not be found.)

根据其他一些研究,我得出结论,我的问题与一些.dll文件有关。我使用的两种系统字体是“monospace”和“Arial”。在

有谁能详细解释一下这个问题的解决方法吗?在


Tags: theinlinenotloadbeexefile
1条回答
网友
1楼 · 发布于 2024-10-03 04:32:36

我也有同样的问题,原因是py2exe重视SDL_ttf.dll文件作为系统拥有的dll,并将其从分发包中排除。 你可以在你的设置.py在

origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
       if os.path.basename(pathname).lower() in ["sdl_ttf.dll"]:
               return 0
       return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL

您也可以访问http://thadeusb.com/weblog/2009/4/15/pygame_font_and_py2exe获取更多信息

相关问题 更多 >