[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] How to set up PyGame with Eclipse (PyDev plug-in)?
Well, I just tried to run this Python program (from within Eclipse
configured with PyDev):
import pygame
from pygame.locals import *
screen_mode = (640, 480)
color_black = 0, 0, 0
class Game:
def __init__(self):
pygame.init()
self.screen = pygame.display.set_mode(screen_mode)
pygame.display.set_caption("Pygame intro")
self.quit = False
def update(self):
return
def draw(self):
self.screen.fill(color_black)
pygame.display.flip()
def mainLoop(self):
while not self.quit:
for event in pygame.event.get():
if event.type == QUIT:
self.quit = True
self.update()
self.draw()
if __name__ == '__main__':
game = Game()
game.mainLoop()
And this is what I got:
Traceback (most recent call last):
File "/Users/untz/DevProjects/Python/pygame_tutorial1/src/main.py",
line 1, in <module>
import pygame
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/pygame/__init__.py", line 159, in <module>
try: import pygame.surfarray
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/pygame/surfarray.py", line 69, in <module>
import pygame._numericsurfarray as numericsf
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/Numeric/Numeric.py", line 358, in <module>
from dotblas import dot, innerproduct, vdot
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/numarray/dotblas.py", line 5, in <module>
import generic as _gen
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/numarray/generic.py", line 13, in <module>
import numerictypes as _nt
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/numarray/numerictypes.py", line 168, in <module>
Byte = _register("Byte", Int8)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/numarray/numerictypes.py", line 68, in _register
raise ValueError("Type %s has already been registered" % name)
ValueError: Type Byte has already been registered
On Feb 26, 2008, at 12:46 AM, Unnsse Khan wrote:
Brian,
Very cool! Maybe there is something that's just wrong with mine...
when you are editing the file is the pydev perspective openeded?
Yes, I created a new Pydev project (in Eclipse) and added all of
my .py files in the src folder (underneath the project).
The PyDev Package Explorer view is opened along with the workspace
file which I am editing.
Ignoring the problem, Does the code run OK?
Yes, I ran a sample PyGame app using Eclipse and saw the frame
(window) generated in black appear. :-)
is your top registered Python interpreter
(Preferences/PyDev/Interpreter - Python) the framework python like
this:
yes
How did you configure PyGame to the PYTHONPATH inside Eclipse?
Did you also place additional libraries like Numeric, etc?
Happy programming,
Unnsse
P.S. This is what happens when I type in "locate pygame" from the
command line:
/Developer/Python/py2app/Examples/pygame
/Developer/Python/py2app/Examples/pygame/English.lproj
/Developer/Python/py2app/Examples/pygame/English.lproj/MainMenu.nib
/Developer/Python/py2app/Examples/pygame/English.lproj/MainMenu.nib/
JavaCompiling.plist
/Developer/Python/py2app/Examples/pygame/English.lproj/MainMenu.nib/
_MainMenu_EOArchive_English.java
/Developer/Python/py2app/Examples/pygame/English.lproj/MainMenu.nib/
classes.nib
/Developer/Python/py2app/Examples/pygame/English.lproj/MainMenu.nib/
info.nib
/Developer/Python/py2app/Examples/pygame/English.lproj/MainMenu.nib/
keyedobjects.nib
/Developer/Python/py2app/Examples/pygame/English.lproj/aliens.icns
/Developer/Python/py2app/Examples/pygame/aliens.py
/Developer/Python/py2app/Examples/pygame/aliens_bootstrap.py
/Developer/Python/py2app/Examples/pygame/data
/Developer/Python/py2app/Examples/pygame/data/alien1.gif
/Developer/Python/py2app/Examples/pygame/data/alien2.gif
/Developer/Python/py2app/Examples/pygame/data/alien3.gif
/Developer/Python/py2app/Examples/pygame/data/background.gif
/Developer/Python/py2app/Examples/pygame/data/bomb.gif
/Developer/Python/py2app/Examples/pygame/data/boom.wav
/Developer/Python/py2app/Examples/pygame/data/car_door.wav
/Developer/Python/py2app/Examples/pygame/data/explosion1.gif
/Developer/Python/py2app/Examples/pygame/data/house_lo.wav
/Developer/Python/py2app/Examples/pygame/data/player1.gif
/Developer/Python/py2app/Examples/pygame/data/shot.gif
/Developer/Python/py2app/Examples/pygame/setup.py
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/Py2App/py2app/recipes/pygame.py
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/Py2App/py2app/recipes/pygame.pyc
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/Py2App/py2app/recipes/pygame.pyo
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/
python/py2app/recipes/pygame.py
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/
python/py2app/recipes/pygame.pyc
On Feb 25, 2008, at 9:31 PM, Brian Fisher wrote:
I use pydev exclusively for all my python work on mac and win.
I'm also running OS X Leopard, with Eclipse 3.3.1.1, a framework
build
of Python 2.5, Pygame 1.8.0rc3 with pydev 1.3.13 and the code you
posted doesn't show a problem for me...
when you are editing the file is the pydev perspective openeded?
is your top registered Python interpreter
(Preferences/PyDev/Interpreter - Python) the framework python like
this:
/Library/Frameworks/Python.framework/Versions/2.5/Resources/
Python.app/Contents/MacOS/Python
?
Ignoring the problem, Does the code run OK?
On Mon, Feb 25, 2008 at 4:35 PM, Unnsse Khan <untz786@xxxxxxxxx>
wrote:
Hello there,
My system configuration is:
(1) OS X Leopard
(2) Eclipse 3.3.1 Europa
(3) Python 2.5
(4) PyGame 1.8.0rc3 (http://rene.f0o.com/~rene/stuff/macosx/)
(5) PyDev 1.3.13 (Eclipse plug-in)
Inside Eclipse's Preferences pane under: PyDev / Python-
Interpreter /
System PYTHONPATH, I have the included the following libraries:
pygame, Numeric, Py2App, etc
I am able to write Python apps using PyGame from the command line
and
I am also able to run them from within Eclipse.
The problem I am experiencing is that if I write something as
trivial
as this:
import sys, pygame
pygame.init()
Eclipse places a curly red line underneath init() and states this in
the Problems view:
"Undefined variable from import: init"
Does anyone on this mailing list use Eclipse's PyDev plug-in to help
write their prospective Python / PyGame apps?
Happy programming,
Unnsse