简体   繁体   中英

Pygame font not working after py2exe

I have this code that works fine when I convert it to an .exe with py2exe, except when it tries to load text on the screen. It comes up with the error:

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.)

Based on some other research, I have come to the conclusion that my problem has to do with some .dll files. The two SysFonts that I am using are 'monospace' and 'Arial'.

Can Anyone please explain a fix to this problem it detail?

I have the same problem,the reason is that py2exe regards the SDL_ttf.dll file as a system owned dll and excludes it from the distribution package. You can add this code on your 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

also you can vist http://thadeusb.com/weblog/2009/4/15/pygame_font_and_py2exe for more infomation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM