Skip to content Skip to sidebar Skip to footer

Pygame Font Error

So I decided to start making a game and I was testing it a bit and then I got this error: Traceback (most recent call last): File 'TheAviGame.py', line 15, in

Solution 1:

You never initialized pygame and pygame.font after importing:

# imports

pygame.init() # now use display and fonts

Solution 2:

In order to use some pygame modules, either pygame or that specific module has to be initialised before you start using them - this is what the error message is telling you.

To initialize pygame:

import pygame
...
pygame.init()

To initialize a specific library (eg font):

import pygame
...
pygame.font.init()

In most cases, you will want to initialise all of pygame, so use the first version. In general, I would place this at the top of my code, just after importing pygame

Solution 3:

You put None in the font:

font = pygame.font.Font(None, 25)

You can’t do that. You have to put a type of font there.

And you should call pygame.init().

Post a Comment for "Pygame Font Error"