1

セットアップ ファイルに次のコードを記述し、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')

何か問題がありますか?

4

1 に答える 1

0

あなたの小切手

if os.path.basename(pathname).lower() in ["sdl_ttf.dll", "SDL.dll"]:

lower()ファイル名を呼び出しているため動作しませんが、SDL.dll代わりに を使用するsdl.dllため、py2exe には sdl ライブラリが含まれません。

Pygame Wikiからこのスクリプトを使用してみることもできます。

于 2012-07-24T06:35:49.227 に答える