Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

library not initialized (pygame)

279 views
Skip to first unread message

Quentin Bock

unread,
May 2, 2021, 3:23:50 PM5/2/21
to
Code:
#imports and variables for game
import pygame
from pygame import mixer
running = True

#initializes pygame
pygame.init()

#creates the pygame window
screen = pygame.display.set_mode((1200, 800))

#Title and Icon of window
pygame.display.set_caption("3.02 Project")
icon = pygame.image.load('3.02 icon.png')
pygame.display.set_icon(icon)

#setting up font
pygame.font.init()
font = pygame.font.Font('C:\Windows\Fonts\OCRAEXT.ttf', 16)
font_x = 10
font_y = 40
items_picked_up = 0
items_left = 3

def main():
global running, event

#Game Loop
while running:
#sets screen color to black
screen.fill((0, 0, 0))

#checks if the user exits the window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()

def display_instruction(x, y):
instructions = font.render("Each level contains 3 items you
must pick up in each room.", True, (255, 255, 255))
instructions_2 = font.render("When you have picked up 3 items,
you will advance to the next room, there are 3.", True, (255, 255, 255))
instructions_3 = font.render("You will be able to change the
direction you are looking in the room, this allows you to find different
objects.", True, (255, 255, 255))
clear = font.render("Click to clear the text.", True, (255,
255, 255))
screen.blit(instructions, (10, 40))
screen.blit(instructions_2, (10, 60))
screen.blit(instructions_3, (10, 80))
screen.blit(clear, (10, 120))

if event.type == pygame.MOUSEBUTTONDOWN:
if event.type == pygame.MOUSEBUTTONUP:
screen.fill(pygame.Color('black')) # clears the screen text

display_instruction(font_x, font_y)
pygame.display.update()


main()

the error apparently comes from the first instructions variable saying
library not initialized not sure why, its worked before but not now :/

Michael Torrie

unread,
May 2, 2021, 4:04:40 PM5/2/21
to
On 5/2/21 1:23 PM, Quentin Bock wrote:
> the error apparently comes from the first instructions variable saying
> library not initialized not sure why, its worked before but not now :/

I don't get that error on my Fedora 32 machine. The script ultimately
doesn't run because it can't find the icon png file. But the window
briefly appears and it seems like pygame is being initialized properly.


Cosmo Hope

unread,
Feb 18, 2022, 7:23:52 PM2/18/22
to
i have the same problem currently
have you found a solution by chance.

Martin Di Paola

unread,
Feb 19, 2022, 2:27:04 PM2/19/22
to
Could you share the traceback / error that you are seeing?
>the error apparently comes from the first instructions variable saying
>library not initialized not sure why, its worked before but not now :/
>--
>https://mail.python.org/mailman/listinfo/python-list
0 new messages