pythonfontspygame

Font module not available error in Pygame


Running Python 2.7.2, and Pygame 1.9.2pre on OS X.

Another noobious issue: Initialising the pygame.font module produces an error that I dare not... well, attempt to solve myself. I'm guessing this is a rather generic pygame-related issue... but I haven't been able to find any solutions.

import pygame
pygame.init()

pygame.font.init()

Gives:

Desktop/font.py:4: RuntimeWarning: use font: dlopen(/Library/Python/2.7/site-packages/pygame/font.so, 2): Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /Library/Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf
  Reason: image not found
(ImportError: dlopen(/Library/Python/2.7/site-packages/pygame/font.so, 2): Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /Library/Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf
  Reason: image not found)
  pygame.font.init()
Traceback (most recent call last):
  File "Desktop/font.py", line 4, in <module>
    pygame.font.init()
  File "/Library/Python/2.7/site-packages/pygame/__init__.py", line 70, in __getattr__
    raise NotImplementedError(MissingPygameModule)
NotImplementedError: font module not available
(ImportError: dlopen(/Library/Python/2.7/site-packages/pygame/font.so, 2): Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /Library/Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf
  Reason: image not found)

What exactly is wrong here and how to resolve it?

I am using 64 bit version of Python with 32 bit Pygame (there seems to be no 64 bit Pygame available for Mac OS).


Solution

  • Problem: Using 32-bit Pygame with 64-bit Python generally isn't a good idea.

    Solution: Always use Python and Pygame both in 64-bit architecture. (Or 32).

    Currently there doesn't seem to be a 64-bit Pygame for OS X, so you'll have to use a 32-bit Python.

    After installing a 32-bit Python you may need to re-install the 32-bit Pygame for it to have any effect. This is what happened to me