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 7512269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:48:44+00:00 2026-05-29T23:48:44+00:00

Whenever i try and run my pygame program in which I’m trying to load

  • 0

Whenever i try and run my pygame program in which I’m trying to load some images I always get plain “pygame.error” and nothing else.

I have imported pygame aswell as pygame.locals. At first i thought that it was because it couldnt find my files but whenever I change the name of a file to something thats incorrect it says “couldnt open image” so i guess that it really does find the file but fails when trying to load it. the startup() function is the first thing that is run from main. and i’ve also tried to do a simple grass=pygame.image.load(‘grass.png’) with the grass.png file in the same directory as the python file

thankful for all the help i can get

….. line 41, in startup
surroundingsdict = {‘gräs’: pygame.image.load(os.path.join(‘images’, ‘grass.png’)).convert_alpha(),
pygame.error

def startup():
    pygame.init()
    p1=Player.Player(int(random.random()*mapstorlek),int(random.random()*mapstorlek))
    vh=ViewHandler.ViewHandler()
    surroundingssdict = {'grass': pygame.image.load(os.path.join('images','grass.png')).convert(),
          'mount': pygame.image.load(os.path.join('images', 'mount.png').convert)()}
    playerdict={'p1': pygame.image.load(os.path.join('images','player.png')).convert()}
  • 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-05-29T23:48:45+00:00Added an answer on May 29, 2026 at 11:48 pm

    pygame.error is usually accompanied by a message with more details about what went wrong, like the ‘couldn’t open image’ you get when you try a non-existant image. Are you sure you get no more info? Can’t be sure what’s wrong, but I’ll throw out two suggestions:

    Do you call pygame.display.set_mode to set a display surface before loading the images? You might be doing that in your ViewHandler class, but if not the convert() will fail since it changes the pixel format of the surface to match the display, which it of course can’t do if there is no display active.

    Another possibility is that you don’t have full image support in pygame and can’t load .png. Have you tried loading other formats? Try calling pygame.image.get_extended() to see if your pygame is built with extended image support. Even if it returns True there is no guarantee that you can load .png, but at least it’s more likely to be something else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

python version: 2.71 I get a syntax error whenever I try to run it
Whenever i try to run sqlmetal, i get this: 'sqlmetal' is not recognized as
Whenever I try to install a Click Once application, I always get a 404
whenever I try to call my ejb from a client, I get this error
I get the above error whenever I try and use ActionLink ? I've only
I am getting an error whenever i try to run following unzip command from
This code returns me an error whenever I try to run this code. Can
For some reason, whenever I now try and run my SL4 application out-of-browser, when
I am getting this error whenever I try to run GCC outside of its
My xcode have crashed giving following error whenever I try to run my already

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.