Skip to content

pygame_sdl2.font ImportError when running programs frozen with PyInstaller #94

@MyreMylar

Description

@MyreMylar

I've spent some time poking at making a usable windows .exe file of my pygame_sdl2 project with PyInstaller. After a fair bit of fiddling around and learning the ropes I've found two issues so far:

  1. The json library, is not included automatically by PyInstaller. I assume this is related to the way it is being dynamically imported somewhere in pygame_sdl2. Luckily it has a fairly easy fix in that you can just 'import json' in your own code and it will be included in your frozen distribution. It would be nice to make pygame_sdl2 handle this itself though.

  2. pygame_sdl2.font fails to import at runtime after freezing. Googling around seems to suggest this can come from a missing .dll file, but I'm at a loss as to exactly what that could be as the error helpfully gives no specifics. I have the obvious SDL_ttf.dll and SDL2_ttf.dll in there. In case it helps here is a screenshot of all the dlls PyInstaller scoops up into it's distribution directory:

alt text

Of course it could be something else related to the font module and not dlls causing the import error.

However, if you remove all traces of pygame_sdl2 font from your application it appears to build and run fine. So we are so close to functional here!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions