Hey guys, recently I started playing around with pygame. Right now im making a little orb move when you hit a key. But its stuck with the image loading!

background_image_filename = 'C:\\orb\\backroundorb.jpeg'
sprite_image_filename = 'C:\\orb\\orbsprite.jpeg'

import pygame
from pygame.locals import *
from sys import exit

pygame.init()



screen = pygame.display.set_mode((640, 480), 0, 32)

background = pygame.image.load(background_image_filename)
sprite = pygame.image.load(sprite_image_filename)

does anyone see the problem with this part of the code? It comes up with the error message

Traceback (most recent call last):
File "C:\Python25\orb", line 14, in <module>
background = pygame.image.load(background_image_filename)
error: Couldn't open C:\orb\backroundorb.jpeg

There is a folder called orb and there are images called
backroundorb.jpeg and orbsprite.jpeg.

Can anyone help me with this?

In my file name i mispelled background and spelled it backround. I was to lazy to fix it so its still backroundorb.jpeg

Hi rysin,

Can you open the file at all from within python? If you say

f = open("C:\\orb\\backroundorb.jpeg", "r")

does that work?

No it doesnt haha! What do you think is wrong with it? IM on a compaq computer... do I put that in the path name?

Hi rysin,

Maybe try importing os and run os.listdir() on the given directory. Do the following and please tell me what you get:

import os
os.listdir("C:\\orb")

Or maybe it could be some kind of weirdness in processing the backslashes? I'm not at a Windows PC, so I can't tell.

THis is what I got

>>>
>>>
It just skipped to a new line

YES! After many many hours(3 to be exact!) of debugging I found the problem. It was actually later in the program! Thanks to all who helped!

This question has already been answered. Start a new discussion instead.