Running:
Mac OSX mountain Lion 10.8.3
Python 2.7.2
Pygame 1.9.2
I have a simple python pygame program that displays an image on the screen, this works great when I run it in my IDE. The problem comes when try to make it a standalone program using py2app I get the Error:
pygame.error: File is not a Windows BMP file
I did some research and found out that it is probably an error with pygame or SDL_image.framework so I reinstalled both and I get the same error. However, when I do use a BMP image the program works fine although I cannot use image formats such as .png or .jpg.
window.py:
import pygame,sys
from pygame.locals import *
pygame.init()
size=[700,500]
screen=pygame.display.set_mode(size)
clock=pygame.time.Clock()
img = pygame.image.load("Images/img.png") # Error generated here
# -------- Main Program Loop -----------
while True:
# ALL EVENT PROCESSING SHOULD GO BELOW THIS COMMENT
for event in pygame.event.get():
if event.type == QUIT:
isRunning = False
pygame.quit()
sys.exit()
screen.blit(img,(300,300))
pygame.display.flip()
clock.tick(20)
If it is of any use, here is my setup.py file:
from setuptools import setup
APP = ['window.py']
DATA_FILES = [('', ['images'])]
OPTIONS = {'argv_emulation': True}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Problem Solution for 2.7.2:
Turns out my pygame files got or were corrupted. To solve the problem I replaced my old pygame files within the application with new pygame files. The pygame folder in the application is located at "app.app/Contents/Resources/lib/python2.7/lib-dynload". Replace the old pygame folder with this one and hopefully it will work:
https://dl.dropboxusercontent.com/u/84011326/Youtube%20files/pygame.zip
Other Solution
I downloaded python version 2.7.5 for mac and this simply fixed all errors from not being able to load the pygame mixer to being able to load jpg and png images.