1 Replies - 2854 Views - Last Post: 28 March 2011 - 11:10 AM Rate Topic: -----

#1 tpgames  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 24-February 11

Unable to load image in Python/Pygame

Posted 28 March 2011 - 09:28 AM

I can't figure out why it can't open the image, nor how to fix it. I am on a Mac 10.04 OS X, using Python 2.6 and Pygame 2.6. And yes, I am tired of tutorials whose code that does not work on my Mac with my python and my pygame. :P Its impossible to learn python that way! I'm trying to run this in shell as I can not compile anything on my mac as that feature doesn't work either. (Don't know how to use .egg and haven't reresearched it yet for my OS).

Lastly, the image module it doesn't find and I thought Pygame deals with images. I did try to import the image module.
Thanks! :D


#!/usr/bin/python2.6



import pygame
from pygame.locals import *
from sys import exit


pygame.init()
# file:///Users/kytriya/Desktop/

background_image_filename = 'jadeuniversity.png'
mouse_image_filename = 'handle.png'

screen = pygame.display.set_mode((1000, 900), 0, 32)
pygame.display.set_caption("Jade University Mouse Movement")

background = pygame.image.load(background_image_filename).convert()
mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            exit()
            
    screen.blit(background, (0,0))
    
    x, y = pygame.mouse.get_pos()
    x-= mouse_cursor.get_width() / 2
    y-= mouse_cursor.get_height() / 2
    screen.blit(mouse_cursor, (x,y))
    
    pygame.display.update()




Traceback (most recent call last):
  File "/Users/kytriya/Desktop/CodeLearning/Python/PyCode-Mine/MouseCursorMovement.py", line 18, in <module>
    background = pygame.image.load(background_image_filename).convert()
error: Couldn't open file:///Users/kytriya/Desktop/jadeuniversity.png
>>> ================================ RESTART ================================
>>> ================================ RESTART ================================
>>> 

Traceback (most recent call last):
  File "/Users/kytriya/Desktop/CodeLearning/Python/PyCode-Mine/MouseCursorMovement.py", line 18, in <module>
    background = pygame.image.load(background_image_filename).convert()
error: Couldn't open jadeuniversity.png



Is This A Good Question/Topic? 0
  • +

Replies To: Unable to load image in Python/Pygame

#2 tpgames  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 24-February 11

Re: Unable to load image in Python/Pygame

Posted 28 March 2011 - 11:10 AM

Sorry, but I'm beyond frustrated and writing this as nicely as I can. I'm not upset with anyone here, but rather the lack of support for the only computer I can keep running.

I tried downloading PIL, but it is really a Windows thing. The "source code for all systems" I doubt works on my Priviledged Ancient Crap Mac.
I tried putting the Image Module in the Python 2.6 folder. It won't find it. Here's the file output. And the PIL site is useless for info! They don't even recognize that they even know what a Mac is, let alone that something called a Mac exist!

Yes, I'm trying to save for a glorious viral, breakdownable PC only because no one gives a crap about macs, including the Black Hats. :P (So far I only have $40 saves towards new computer.) However, it would be nice if I could get something besides Ren'Py working. Ren'Py doesn't exactly make it easy to learn as their tutorials are still lacking in examples. And those examples are too simplistic and outside of 'real world applications' as far as RPG's are concerned. I often wonder if I'd have better luck with C++ with OpenGL to get around silly "OS specific coding requirements".

Thanks!

['/Users/kytriya/Desktop/CodeLearning/Python/PyCode-Mine', 
'/Users/kytriya/Documents', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages']
>>> 


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1