ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

使用pygame2exe时字体模块错误

2019-10-11 02:56:51  阅读:233  来源: 互联网

标签:py2exe python pygame


我使用了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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有