【问题标题】:Pygame font not working after py2exePygame字体在py2exe之后不起作用
【发布时间】:2014-02-15 16:20:56
【问题描述】:

当我使用 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 文件有关。我使用的两个 SysFonts 是“monospace”和“Arial”。

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

【问题讨论】:

  • 我尝试过使用 .ttf 文件,但也没有用

标签: python python-2.7 pygame py2exe


【解决方案1】:

我也有同样的问题,原因是 py2exe 将 SDL_ttf.dll 文件视为系统拥有的 dll 并将其从分发包中排除。 您可以在 setup.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 了解更多信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-23
    • 2014-01-30
    相关资源
    最近更新 更多