I am using the following code on my raspberry pi (with debian as the os), and when i run it, it says:

cannot load image C:/root/desktop/Snake.bmp

*

Traceback (most recent call last):
  File "/root/game.py", line 25, in <module>
    background, tmp_rect = load_image('Snake.bmp')
  File "/root/game.py", line 11, in load_image
    raise SystemExit, message
SystemExit: Couldn't open C:/root/desktop/Snake.bmp
>>> cannot load image C:/root/desktop/Snake.bmp

*
this is the code:

*

import pygame, os
import random
from pygame.locals import

def load_image(name, colorkey = -1):
    fullname = os.path.join('C:/root/desktop', name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error, message:
        print 'cannot load image', fullname
        raise SystemExit, message
    image =image.convert()
    if colorkey is not None:
        if colorkey is -1:
            colorkey = image.get_at((0,0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image, image.get_rect()

def AllKeysUp(key):
    return key.type == KEYUP

pygame.init()
screen = pygame.display.set_mode((500,600))
pygame.display.set_caption('snake_run')
background, tmp_rect = load_image('Snake.bmp')
screen.blit(background, (0,0))
pygame.display.flip()

*

the image is where it should be (on the desktop)

also i tried without the C:, and it came up with the same error (well... almost)

anyone know what i am doing wrong?

Recommended Answers

All 4 Replies

Check the permissions first. Does the user (you) have permission to open the file?

On Linux filenames are case sensitive, so check that too.

Check the permissions... How? I am unfortunately a noob at linux...

I do know that i got the name of the file correct though :)

ls -l or use one of the GUIs like midnight commmander (google "linux file permissions" for more info). Note that you will have to be root or sudo to change them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.