Python Forum
FileNotFoundError when I try putting sprite in Pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FileNotFoundError when I try putting sprite in Pygame
#1
I started following a Space Invaders tutorial for pygame, and I made sprites in Piskel and put them into the folder with my game, but I got an error saying "FileNotFoundError: No such file or directory." Note that I am very new to pygame. I tried many ways, but it still comes up with the same error, which are listed below.

- pygame.image.load("cannon.png")
- pygame.image.load("cannon.gif")
- pygame.image.load("\Users\ZULU\AppData\Local\Programs\Python\Python37-32\Zion_Python Games\First Pygame\cannon.png")
- pygame.image.load("/Users/ZULU\AppData/Local/Programs/Python/Python37-32/Zion_Python Games/First Pygame/cannon.png")
- pygame.image.load(os.path.abspath("cannon.png"))
- pygame.image.load(os.path.abspath("\Users\ZULU\AppData\Local\Programs\Python\Python37-32\Zion_Python Games\First Pygame\cannon.png"))

Also, I tried checking if the path existed, but It always appeared False.

os.path.exists('/Users/ZULU/AppData/Local/Programs/Python/Python37-32/Zion_Python Games/First Pygame/cannon.png')

I'm just not sure what to do.
Reply


Messages In This Thread
FileNotFoundError when I try putting sprite in Pygame - by zionkozisek - Nov-28-2020, 09:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Sprites just randomly appear and dissapear in my pygame.sprite.GoupeSingle trueShadoWrr 2 2,039 Feb-13-2023, 09:34 AM
Last Post: Vadanane
  [PyGame] Pygame is treating blob_group as a surface, when I need it to treat it as a Sprite. Swagford 1 1,346 Jan-24-2023, 09:58 PM
Last Post: metulburr
  [PyGame] My Pygame Sprite not appearing... noodlespinbot 3 3,885 Oct-30-2020, 06:51 AM
Last Post: robinmurphy
  My Pygame Sprite not appearing... noodlespinbot 1 2,293 Apr-08-2020, 11:25 AM
Last Post: pyzyx3qwerty
  [PyGame] Sprite image.get_rect() moves sprite to 0, 0 michael1789 2 4,637 Dec-13-2019, 08:37 PM
Last Post: michael1789
  Pygame sprite not moving michael1789 1 2,880 Nov-10-2019, 03:54 AM
Last Post: michael1789
  Sprite not rendering Clunk_Head 2 2,192 Oct-03-2019, 11:27 AM
Last Post: Clunk_Head
  Need help making a sprite GalaxyCoyote 4 3,308 Aug-11-2019, 09:12 PM
Last Post: metulburr
  moving a sprite pfaber11 3 2,636 May-15-2019, 12:52 PM
Last Post: pfaber11
  Pygame Class Sprite Placement Confusion TheHumbleIdiot 2 3,609 Sep-11-2018, 02:19 PM
Last Post: TheHumbleIdiot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020