49552/python-error-pygame-error-couldn-t-open-pygame-png
I'm trying to build the snake game using pygame. I'm following this tutorial.
I end up with the following error:
pygame.error: Couldn't open pygame.png
icon = pygame.image.load('spaceship.png') pygame.error: Couldn't open spaceship.png I am getting this error,\anyone?
Hope this Helps!!
To learn more, join the online course to do Masters in Python.
Thanks!
Hey, @There,
Are you facing the exact same error which is mentioned above while executing your code?
my code is like this
import pygame import sys screen = pygame.display.set_mode([680, 480]) pygame.init() screen.fill([130, 0, 200]) class Block(pygame.sprite.Sprite): def __init__(self,file_name,location): img = pygame.image.load(file_name) pygame.sprite.Sprite.__init__(self) self.image = pygame.Surface([width,height]) self.image.fill(color) self.rect = self.image.get_rect() pygame.image.load('ball(2)') while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() pygame.display.flip()
Hi, @There,
So using this code you want to conclude that there is no error after executing it?
add import os at top of your ...READ MORE
Try installing libpng You can do it with ...READ MORE
You need to download and install the ...READ MORE
pygame.Surface takes in integer values for building ...READ MORE
You must be trying this command in ...READ MORE
file = open('text.txt', 'w+) READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.