Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9252951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:05:27+00:00 2026-06-18T11:05:27+00:00

I’m trying to make the base for a map that I’m going to be

  • 0

I’m trying to make the base for a map that I’m going to be using for a game, but I can’t load the image onto the screen. I’ve tried sending in an absolute filepath to the image with likesame letter case, I’ve tried changing the name of the image, I’ve tried loading different images that worked in other programs I made, and I’ve tried putting the image in the same directory as the script itself. Nothing has worked yet. I looked at a few threads of people who were having the same problem, such as Why are my pygame images not loading? and I can’t find the answer to my problem. The image will not load. Here’s the code:

import sys, pygame
from pygame.locals import *

pygame.init()
size = (600, 400)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Practice Map")
walls = pygame.image.load("C:\Users\dylan\Desktop\Practice Game\brick.jpg")

x = 0
y = 0

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        if event.type == KEYDOWN and event.key == K_ESCAPE:
            sys.exit()
        if event.type == KEYDOWN and event.key == K_UP:
            y -= 20
        if event.type == KEYDOWN and event.key == K_DOWN:
            y += 20
        if event.type == KEYDOWN and event.key == K_LEFT:
            x -= 20
        if event.type == KEYDOWN and event.key == K_RIGHT:
            x += 20
        screen.fill((0,0,0))
        screen.blit(walls,(x, 330))
        # more bricks to go here later
        pygame.display.flip()

#end

and the error:

Traceback (most recent call last):
  File "C:\Users\dylan\Desktop\Practice Game\move.py", line 8, in <module>
    walls = pygame.image.load("C:\Users\dylan\Desktop\Practice Game\brick.jpg")
error: Couldn't open C:\Users\dylan\Desktop\Practice Gamerick.jpg

I’m using Python 2.6 with PyGame 1.9 for Python version 2.6 with IDLE as my editor.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:05:28+00:00Added an answer on June 18, 2026 at 11:05 am

    The problem here is that you’re using \ as a pathname separator, but \ is also used as an escape character in Python strings. In particular, \b means “backspace” (or '\x08'). You get away with the other backslashes because of not-quite-documented-but-reliable behavior that unknown escape sequences like \X are treated as a backslash followed by an X.

    There are three solutions:

    1. Use a raw string, which means Python string escapes are ignored: r"C:\Users\dylan\Desktop\Practice Game\brick.jpg".
    2. Escape your backslashes: "C:\\Users\\dylan\\Desktop\\Practice Game\\brick.jpg".
    3. Use forward slashes instead: "C:/Users/dylan/Desktop/Practice Game/brick.jpg".

    If you’ve memorized the list of Python escape sequences, and are willing to rely on functionality that may change but probably won’t, you can get away with only escaping the \b here, but it should be clear why the other three are better ideas in the long run.

    While Windows pathnames do natively use backslash separators, all built-in and standard-library Python functions, and most functions in third-party libraries, are perfectly happy to let you use forward slashes instead. (This works because Windows doesn’t allow forward slashes in paths at all.)

    To understand how and why this works, you might want to try printing out the strings:

    >>> print "C:\Users\dylan\Desktop\Practice Game\brick.jpg"
    C:\Users\dylan\Desktop\Practice Gamrick.jpg
    >>> print r"C:\Users\dylan\Desktop\Practice Game\brick.jpg"
    C:\Users\dylan\Desktop\Practice Game\brick.jpg
    >>> print "C:\\Users\\dylan\\Desktop\\Practice Game\\brick.jpg"
    C:\Users\dylan\Desktop\Practice Game\brick.jpg
    >>> print "C:/Users/dylan/Desktop/Practice Game/brick.jpg"
    C:/Users/dylan/Desktop/Practice Game/brick.jpg
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.