-1
import pygame

from pygame.locals import *

pygame.init()

screen_width = 800
screen_height = 600

screen = pygame.display.set_mode((screen_width,screen_height))
pygame.display.set_caption('Platformer')

#load images

bg_img = pygame.image.load("img/sky.png")


run = True
while run:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    screen.blit(bg_img, (0,0))

    pygame.display.update()

pygame.quit()

Whenever I try and do This It come up as an Error such as this

FileNotFoundError: No file 'img/sky.png' found in working directory 'C:\Users\yeg20\OneDrive\Desktop\workspace'.

Could anyone tell me why this is happening and how to fix it?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • 1
    The error means what it says. Does `img\sky.png` exist within `C:\Users\yeg20\OneDrive\Desktop\workspace` or not? Fix it by putting the file in the correct location – OneCricketeer Oct 12 '22 at 02:04

1 Answers1

1

You are trying to load an image at the relative path img/sky.png. Your working directory is currently C:\Users\yeg20\OneDrive\Desktop\workspace. You do not have a file at C:\Users\yeg20\OneDrive\Desktop\workspace\img\sky.png

Gradyn Wursten
  • 118
  • 2
  • 18