Question

I am learning Python and Pygame, and have been using PyCharm for Mac. I tried to load a png-image to a Pygame-window, but i got an error: pygame.error: File is not a Windows BMP file. I tried it with IDLE, and it worked fine. What can I do to make it work in PyCharm?. I am using Python 2.7.5

Heres my code:

import pygame, sys
pygame.init()
screen = pygame.display.set_mode([640, 480])
screen.fill([255, 255, 255])
my_ball = pygame.image.load('beach_ball.png')
screen.blit(my_ball, [50, 50])
pygame.display.flip()
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
pygame.quit()
Était-ce utile?

La solution

Try google: "pygame.error: File is not a Windows BMP file"

Here is the first answer I found using google:

FAST SOLUTION for beginners:

install Python 2.7.5

Go into Applications --> Python 2.7 --> update Shell profile

Python 2.7.5 should now be your default python. Run your application with that (in terminal) and it all works.

This is by far the easiest way to get around this problem. Hope this helps.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top