我在安装文件中编写了以下代码,并在默认文件夹中包括sdl_ttf.dll","sdl.dll。但是,它显示了一条错误消息:
NotImplementedError:font module not available
<Import error: DLL load failed:can't find assigned module>
代码
from distutils.core import setup
import py2exe,sys,os
import pygame
setup(console=['blackjack.py'])
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
if os.path.basename(pathname).lower() in ["sdl_ttf.dll", "SDL.dll"]:
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
pygamedir = os.path.split(pygame.base.__file__)[0]
os.path.join(pygamedir, pygame.font.get_default_font()),
os.path.join(pygamedir, 'SDL.dll'),
os.path.join(pygamedir, 'SDL_ttf.dll')
有什么问题吗?
您的支票
if os.path.basename(pathname).lower() in ["sdl_ttf.dll", "SDL.dll"]:
将不起作用,因为您对文件名调用lower()
,但使用SDL.dll
而不是sdl.dll
,因此py2exe将不包括sdl库。
你也可以尝试从pygame wiki中使用这个脚本。