This post assumes that we already have Eclipse installed.
1) Install PyDev in Eclipse
The Python package that is to be used in Eclipse is called PyDev. In order to install it go to
Help -> Install New Software
In the window that pops up, set the “Work with:” value to be http://pydev.org/updates . When prompted for a name just call it Python.
You will see “PyDev” and “PyDev MyLyn Integration“. Just check PyDev and then hit the Next button. Keep clicking Next and agree to the terms of service.
When it asks you to agree to certificates just oblige them by checking the box and saying “Yes”.
2) Configure the Python Interpretter
In order to run Python in Eclipse you have to let Eclipse know where your install directory is located. To do this go to
Window -> Preferences -> PyDev -> Interpreter Python
To the right of Python Interpreters click the button labeled New. This will bring up a popup window asking about Interpreter Name and Interpreter Executable. For the name, call it Python 2.7 (assuming the version we have is 2.7). For the executable, navigate to the python executable. Mine is located at C:Python27python.exe . Then click OK.
Next you will be asked about folders to add to the SYSTEM pythonpath. I just went with the default values shown below. Once you’re happy click OK on the Selection needed popup and OK on the preferences.
3) Import a New Project
Now we’re going to try and import the project that we created in Installing Python on Windows and Connecting it to MongoDB.
File -> New -> Other -> PyDev -> PyDev Project
Uncheck the box “Project contents: Use default”. Then browse to the top-level directory, in our case called PlayPyNLP. Give the project the name PlayPyNLP as well. Finally click “Finish”.
4) Try out the MongoDB project in Eclipse
If all went well we will have a project in the Package Explorer called “PlayPyNLP”. Browse into the src directory to see the script file we created back in Installing Python on Windows and Connecting it to MongoDB.
To run the file, first select it as in the picture above. Next, go to
Run -> Run As -> Python Run
This will execute the script, same as if you typed “python srctest_mongodb_connection.py” in the Command prompt.
Things that go wrong
1) I tried to run the Python script while the MongoDB wasn’t running. To fix it I launched MongoDB.
Speak Your Mind