0

When I was making my first-game this problem occurred.

My code(python):

#IMPORT
import pygame, time, sys
pygame.init()

#Pic in Game
size = 20
bodyPic = pygame.transform.scale(pygame.image.load('white.jpg'),(size, size))
headPic = pygame.transform.scale(pygame.image.load('gray.jpg'),(size, size))
foodPic = pygame.transform.scale(pygame.image.load('red.jpg'),(size, size))

It noticed that "No such file or directory" although all my .jpg file was in the same folder with the above code!

I have tried many way to solve it but I cant (Including write the full path of the file in the "pygame.image.load.()" !)

At least, thank you for reading my problem :">

  • How did you try to use an absolut file path? See [Windows path in Python](https://stackoverflow.com/questions/2953834/windows-path-in-python) – Rabbid76 May 02 '21 at 15:41
  • change the `cwd` of the launch config – rioV8 May 02 '21 at 15:43
  • @Rabbid76 the path of this python file in my computer is C:\Users\Admin\VScode\[PythonCode]\SnakeGame\snake.py So I write the path like this pygame.image.load('C:\Users\Admin\VScode\[PythonCode]\SnakeGame\white.jpg') – BlueCat2209 May 03 '21 at 01:25
  • @rioV8 can you tell me more specifically about how to do that? – BlueCat2209 May 03 '21 at 01:29
  • https://stackoverflow.com/a/57698163/9938317 – rioV8 May 03 '21 at 11:15

0 Answers0