Importing pygame.freetype

Issue #189 closed
Tikhon Belousko created an issue

I'm using Mac OS X 10.9 and when I'm trying to import pygame.freetype I'm getting the following error.

>>> import pygame.freetype
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pygame/freetype.py", line 3, in <module>
    from pygame._freetype import *
ImportError: No module named _freetype

How can I fix it?

Comments (13)

  1. Jason Marshall

    If your pygame is up-to-date, try this instead:

    import os
    os.environ['PYGAME_FREETYPE'] = '1'
    import pygame
    

    Then, pygame.font should be FreeType.

  2. Tikhon Belousko reporter

    This is nice, but I just wanted to try pygame.freetype.Font class. To be honest I don't really need freetype feature right now. Is there any way to import freetype module?

  3. Jason Marshall

    Are you looking for pygame.ftfont.Font? There is no pygame.freetype.Font class class.

    (The existence of two FreeType Python scripts, ftfont.py and freetype.py, is confusing.)

  4. Jason Marshall

    I double-checked for freetype.Font.

    >>> import pygame
    >>> import pygame.freetype
    >>> pygame.freetype.Font
    <type '_freetype.Font'>
    >>> 
    

    So there is indeed a pygame.freetype.Font! I'm sorry. Font must have come from this importation of the _freetype extension module:

    from pygame._freetype import *
    

    The _freetype extension module must not have been built correctly for you.

  5. Jason Marshall

    Yes, you can build it yourself. I was planning to share with you the OS X build script that I got from René, but I recently lost it when a hard drive crashed. :-(

  6. Log in to comment