Monday, November 14, 2011

Using Eclipse for Python on Ubuntu 10.04 LTS

We use Eclipse for Python, Java and C++ development. Eclipse is a fairly large, complicated beast. To stay true to the Unix Philosophy, we use command line tools wherever possible. Also, to reduce potential conflicts between tools and plug-ins, we break up the workspaces so that each development environment has a dedicated workspace.

Download Eclipse

Go to the Eclipse website and download the Eclipse IDE for Java EE Developers. This version comes with a collection of plug-ins that support database access, XML editing, and various other common tasks that you'll need.

Once downloaded, create a folder in your home directory called local/eclipse. Unzip the package you downloaded into this folder.

% cd $HOME/local/eclipse
% tar zvxf $HOME/Downloads/eclipse-jee-indigo-SR1-linux-gtk-x86_64.tar.gz

This unpacks a folder called eclipse. Rename it to eclipse-indigo.

% mv eclipse eclipse-indigo
% ln -s eclipse-indigo current

You will now have a folder layout that looks like the following:

        /eclipse/current -> eclipse-indigo


We've gone to this trouble to make it easier to write scripts that involve Eclipse—even if we upgrade, we only need to point to $HOME/local/eclipse/current. As we mentioned earlier, Eclipse is a complicated application that often requires environmental modifications and parameters tweaks. Rather than typing these out each time, we'll capture our requirements in a bash script.

Eclipse bash Launch Script

Please see the Bash Development Tools article.

Create a script called in mysh.

You can now launch Eclipse with the appropriate parameters and environmental variables &

When you start your Eclipse session, be sure to set the appropriate path to your workspace. In this case, it's $HOME/workspaces/python


PyDev is a useful extension for Eclipse that provides support for code completion and debugging. Once you've launched your Python workspace, install the Pydev extension.

First Project

Let's create our first project. Do not create projects in your workspace! The workspace contains settings unrelated to your project—it's best to keep them separate.

Create a repository for your Python project in BitBucket and check it out into your BitBucket folder. For example, pywork.

  • From Eclipse, create a new PyDev project. Give it the same name as your BitBucket repository (pywork).
  • Uncheck Use default and select the root of pywork.
  • Ensure that Add project directory to PYTHONPATH? is selected.

You'll now have a new PyDev project that you can also add to your shell PYTHONPATH.