Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Pygame work with Pydev?

I'm working off the latest Mac OS trying to set up my programming environment. Right now what I want to do is to get Pygame working with Pydev so I can do my Python programming from Eclipse. What I've done so far is installed Python 2.6 from python.org and then installed pygame 1.9 from the site.

What happens is that when I try running Python from the command line, I am able to import pygame without a hitch, but when I try to do the same thing from Eclipse, it doesn't work.

I think it might be because Pydev doesn't know where to find Python, in which case I would like some help on how to make sure it's pointing to the right one.

Thanks!

like image 451
Catherine Hwang Avatar asked Dec 24 '10 07:12

Catherine Hwang


People also ask

Can you use pygame on Python 3?

Does Pygame work with Python 3? ¶ Yes. Pygame 1.9.

Does Python 2.7 support pygame?

Like Python, Pygame is available for free. You will have to download and install Pygame, which is as easy as downloading and installing the Python interpreter.

What version of Python works with pygame?

Pygame 1.9 is known to work with python versions 2.4, 2.5, 2.6, and 3.1.

Can you install pygame with pip?

The best way to install pygame is with the pip tool (which is what python uses to install packages). Note, this comes with python in recent versions. We use the --user flag to tell it to install into the home directory, rather than globally. If it works, you are ready to go!


1 Answers

I work with Eclipse on Windows, but I believe that the Mac version eclipse should be the same. In Eclipse,

  • click Windows > Preferences,
  • expand PyDev from left side,
  • find Interpreter - Python,
  • switch to Libraries tab,
  • click New Folder on the right hand,
  • navigate to your pygame path, and
  • click Apply and OK.

Turn to your Python project in eclipse,

  • right click on it,
  • choose PyDev - Interpreter/Grammar,
  • choose Python as Project type,
  • choose 3.0 or your correspond Python version from Grammar,
  • at last make sure the Interpreter you are using is the same as the one you just configured.

Build your project from eclipse, and it should work.

like image 82
Will.Cai Avatar answered Sep 23 '22 21:09

Will.Cai