[Tutor] accessing an image with pygame.image.load()

bob gailer bgailer at gmail.com
Tue Nov 4 00:05:05 CET 2008


Christopher Spears wrote:
> I want to access a spaceship image with pygame.image.load(), so I wrote
>
>
> self.image = pygame.image.load("C:Users\Chris\Documents\python\assignment07\chris_graphics\spaceship.gif")
>
> However, I got this error message:
>
> error: Couldn't open C:Users\Chris\Documents\python\assignment07\chris_graphics\spaceship.gif
>
> I can't give pygame.image.load a path?  Does anyone know how I would load an image located in a seperate directory?
>   

Since \ is used to "escape" certain characters it is advisable to either 
use \\ or preface the string with r.

   "C:Users\\Chris\\ etc.
OR r"C:Users\Chris\ 



That *might* solve your problem. it is unfortunate that the error 
messages say can't open rather than file not found.

-- 
Bob Gailer
Chapel Hill NC 
919-636-4239

When we take the time to be aware of our feelings and 
needs we have more satisfying interatctions with others.

Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?



More information about the Tutor mailing list