0

Following an online game building tutorial on Youtube, I am trying to build a game but whenever i enter this code it always comes out with this syntax error:

line 11, in <module>
    icon = pygame.image.load('burger.png')
pygame.error: Couldn't open burger.png

what should I do?

martineau
  • 119,623
  • 25
  • 170
  • 301
  • where is situated the image? – juuso Mar 22 '20 at 17:45
  • 1
    Does this answer your question? [Python - error: couldn't open .png file](https://stackoverflow.com/questions/42335678/python-error-couldnt-open-png-file) – juuso Mar 22 '20 at 17:46
  • 1
    On hard drive, in same folder as the code itself but with all other games i had built and put there – maroof hamid Mar 22 '20 at 17:47
  • @maroofhamid if the code is in the projects root folder, see my answer below for ensuring you provide the correct relative or absolute path. – Tanner Dolby Mar 28 '20 at 00:27

1 Answers1

0

Probably nothing to do with Pygame itself. But your file location. Do you have it in the same folder as your .py script (aka your root folder)? If yes, check this thread out: Opening images with Python

robo-monk
  • 134
  • 3
  • 9