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)
        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

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


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?

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.

Edited 4 Years Ago by woooee

This article has been dead for over six months. Start a new discussion instead.