Tuesday, September 22, 2009

PyDev - the Python IDE to Use

CPythonImage via Wikipedia

If you have been following this blog, you know that I have been evaluating which Integrated Development Environment (IDE) for Python is best for me. My co-worker found PyDev which runs in the Eclipse environment. Upon trying it out and both of us evaluating, PyDev is going to be what we are going to use to convert an AML project to Python. We chose this IDE for the following reasons:

1. IDE is based on Java - this means that Eclipse run on almost any platform: Windows - Mac - Linux - Unix
2. Free - Costs nothing to install or use
3. Python works in Eclipse and IronPython (a .Net Framework platform) and Jython (a Completely Java platform).
4. Can be pointed to any version of Platform that we need including Python 2.5 used by ArcGIS.
5. Good textual editor
6. Excellent debugging tools
7. Not too difficult to install.

I just learned how to install it today in Windows. It must be installed and then configured correctly.
0. Get the Python libraries and interpreter from
1. Make sure you have the latest JVM (Java Virtual Machine) installed on your computer. If you don't have it, get it free from http://www.java.com/en/download/index.jsp
2. Download Eclipse by downloading eclipse-jee-galileo-win32.zip
3. Unzip it into any folder on your c:\ drive that you want.
4. Download PyDev from http://sourceforge.net/projects/pydev/files/pydev/Pydev%201.5.0/org.python.pydev.feature-1.5.0.1251989166.zip/download
5. org.python.pydev.feature-1.5.0.1251989166.zip is a zip file that contains all you need to complete the installation. You just unzip the files in the Features folder and put them in the Features folder installed by the Eclipse zip file and you do the same with the files in the plugins folder.
6. Start Eclipse by double clicking on Eclipse.exe Choose the location for your worksapce

Image Hosting

7. Start at the top menu and select Windows - > Preferences

Image Hosting

8. Hit the "New"button and select the python executable for the version you want to use. For me I picked the 2.5 version of python and select all the libraries. Then hit "Apply" then "OK"

Image Hosting

9. Select File -> New -> PyDev Project. Enter the required information. Make sure that the "Grammar Version" matches the Interpreter you chose for the project. It is 2.5 In my Case.

10 Add source code to Project. If you are writing a new module, right-click on project name and choose New. Select the type of file you want to add and to what folder.

Image Hosting

11. Alternatively, you can import a file into the project from omne folder to another folder. Right-click on project name and choose Import.

Image Hosting

12. Now that your project has code to run, Right click on project name -> Properties and select Run/Debug settings on the left.

Image Hosting

13. Select the new button and select "Python Run" and then name your configuration whatever you want. On the main tab, browse for the name of the project to run asnd the name of main module

Image Hosting

14. On the Arguments tab is where you enter your input arguments of the scripts and for the interpreter

Image Hosting

In this example I'm testing a script that take a string of temperatures converts them from Fahrenheit to Celsius and then Celsius to Fahrenheit

15 Hit the apply button
16. The select Run -> Run to run the script!

Image Hosting

Reblog this post [with Zemanta]

No comments: