Eclipse – How to make Pygame work with Pydev

eclipsepydevpygame

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!

Best Answer

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.

Related Topic