Okay, here's my temporary fix:

1. Add a default font file in your game.  My choice is the 'freesansbold.ttf' as this one does seem standard and is included in Pygame (you'll find it in its source code, if nothing else, or site-packages/pygame/freesansbold.ttf).
2. Add a few line before creating the font.

import sys

if getattr(sys, "frozen"): # FROZEN executable
    font_family = "./freesansbold.ttf" # Hard-code a local path
else:
    font_family = pygame.font.match_font(font_family)
self.font_object = pygame.font.Font(font_family, font_size)

So we give it the local filename if the executable is frozen. Copy the freesansbold.ttf next to the final executable and try it.  It should work.  Wrap the data file is you like to do so, it all should work.  This is, however, a temporary fix, it would be great to have pkg_resources working, but one step at a time.

Cheers,

Vincent
On 6/21/2019 2:36 AM, Raoul Snyman wrote:
Hi Vincent,

I was just browsing the PyInstaller documentation the other day
looking for something unrelated, but I came across this question in
the FAQ:

What about pkg_resources?
pkg_resources is currently not supported by PyInstaller. This means
that an application using a library which uses the the pkg_resources
API will probably not work out of the box. The only situation in which
it works is when it's being used on .egg files (see above). For
details follow issue #183.

See https://github.com/pyinstaller/pyinstaller/wiki/FAQ

It may be that PyGame is trying to load something via pkg_resources?

I'm sorry I can't be of more help, I'm not very familiar with pygame
or pkg_resources.


On Thu, Jun 20, 2019 at 8:42 AM Vincent Le Goff
<[email protected]> wrote:
Hello,


I'm a new user of PyInstaller and appreciate its simplicity.  I have,
however, noticed a problem when using pygame.


pygame is an interesting Python library to create games.  It handles
basic operations (like a simple 2D window, sound output, keyboard
processing and so on).  When trying to make an executable out of a game
using pygame, everything seems to work... but things break when pygame
attempts to load its fonts.  Here's the end of the traceback I receive
on calling pygame.font.Font (this is in the executable, not the original
Python script):


    File "site-packages\pygame\pkgdata.py", line 50, in getResource
    File "site-packages\pkg_resources\__init__.py", line 1134, in
resource_exists
    File "site-packages\pkg_resources\__init__.py", line 1404, in
has_resource
    File "site-packages\pkg_resources\__init__.py", line 1464, in _has
NotImplementedError: Can't perform this operation for unregistered
loader type


(I am running the pyinstaller script in a virtualenv, which might also
play a role.)


4The problem doesn't seem to come from pygame directly.  I only have the
slightest idea of what pkg_resources actually does.  Does it sound
familiar to you?  And how to fix it?


Thanks for your help,


Vincent

--
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyinstaller.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/4e5a8c6f-c93e-e712-2583-b0da68332a2a%40gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyinstaller.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/7173b323-6ef7-39a3-b2fa-316a3b9722de%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to