0

I am making a pygame (chrome dino game) in which I want the image of the dino.
For that I put the image in the same folder as the code... My code is:

self.image = pygame.image.load('main-character1.png')

But it shows error: FileNotFoundError: No such file or directory.
When I put the full path then only it works!

self.image = pygame.image.load('H:\CODING\Python\Games\Chrome Dino Game Python\main-character1.png')

Pls help I want to just write only small url not full...

THANK YOU...!

1 Answers1

0

try this at the top of the script, make sure that the python file and the image is in the same directory

from pathlib import Path
import os
os.chdir(Path(__file__).parent)

Ved Rathi
  • 327
  • 1
  • 12