Setting Up Eclipse for Python / Django Development

Using Eclipse with PyDev as an IDE for your development on your Django project can be very helpful in many ways. Since it is integrated, the eclipse has the access to some of the compiler’s information, which means you got assistance in code writing. This includes code hinting, auto-completion, error checking, and navigating through libraries by just a single click or two. You also get to have a scheme for your code, making it easier to read.  PyDev comes with a variety of stuff you’d really love. It has Django integration, Code completion, Syntax highlighting, Code analysis, Unittest integration, Interactive console and many others to mention (see

There are four parts to this procedure. First, you need to install JDK since it is the Eclipse prerequisite. You can then proceed to installing Eclipse. Installing PyDev for eclipse is necessary so that working with Django should be on the go. And finally, test the eclipse by creating a sample project.

Installing Java Development Kit (JDK) on Ubuntu

Open a terminal and execute the following line:

sudo apt-get install openjdk-7-jdk

or you can install sunjdk. The sun jdk isn’t included in the official repository, so you need to add a PPA for that.

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-sdk sun-java6-plugin

Installing Eclipse 3.7.2 on Ubuntu

  1. Download Eclipse. You may have to select what package you want to use. Runwget <url> to download the package.
  2. Extract it.
    tar xzf eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz
  3. Move to /opt/folder
    sudo mv eclipse /opt/
    sudo chown –R root:root eclipse
    sudo chmod –R +r eclipse
  4. Create an eclipse executable in your path and save the file.
    sudo touch /usr/bin/eclipse
    sudo chmod 755 /usr/bin/eclipse
    sudo nano /usr/bin/eclipse

    copy this into nano

    #export MOZILLA_FIVE_HOME=”/usr/lib/mozilla/”
    export ECLIPSE_HOME=”/opt/eclipse”
    $ECLIPSE_HOME/eclipse $*
  5. Create a gnome menu item and save the file.
    sudo nano /usr/share/applications/eclipse.desktop

    copy this into nano

                [Desktop Entry]
                Comment=Eclipse IDE
  6. Launch Eclipse.
    eclipse &


Installing PyDev and PyDev Extensions

  1. To install PyDev and PyDev Extensions using the Eclipse Update Manager, you need to use the Help > Install New Software…



  2. Add the update site you want to work with by clicking the ‘Add..’ button.


  3. Select the update site you entered and add a filter for PyDev so that it shows the contents of all the update sites that have PyDev.


  4. Uncheck the ‘Contact all update sites during install to find required software’
  5. Select the two main items to install and click ‘Next’.
  6. You may read the license agreement and if you accept, select the accept radio button and click ‘Finish’.
  7. Eclipse should automatically download the plugin contents and present you to a dialog asking if you want to restart the Eclipse or not.


Using Eclipse and PyDev for Django

This procedure assumes you’ve already installed Eclipse, PyDev as well as Python and Django.

  1. Open up terminal and create a directory for your project. Move to your created directory and runvirtualenv
                $ mkdir mysite
                $ cd mysite
                $ virtualenv env
                $ cd env/
  2. Open Eclipse. Setup the Python Interpreter by clicking the ‘New…’ button. To do this, go to Windows > Preferences and on the left pane, expand PyDev and select Interpreter – Python.



  3. Select the interpreter by browsing to the bin folder of your existing virtualenv and selecting the python executable. Hit the ‘OK’ button when finished.


  4. You need to check the /usr/lib/python2.7. Hit the ‘OK’ button when finished.


  5. Hit the ‘OK’ button when you’re done adding a Python Interpreter.


  6. Create a project on Eclipse by navigating to File > New > Project or Ctrl+n. Navigate and expand the PyDev folder. Select PyDev Django Project and hit ‘Next >’button. This is equivalent to creating a project using a command line :
    $ startproject mysite


  7. Fill in the Project name. Uncheck the ‘Use default’ option under Project contents and browse to the directory you created using the command virtualenv. And make sure you select the ‘Don’t configure PYTHONPATH’ option. Hit ‘Next >’ button.
  8. Setup your database configuration.


  9. Navigate to the Properties of your newly created project by right-clicking the root folder and selecting Properties from the context menu or simply hit Alt+Enter to bring up the Properties Window.


  10. Select PyDev – PYTHONPATH from the left pane and in the Source Folders tab, hit the ‘Add source folder’ button. You will be asked to choose a folder from your project directory.


  11. Hit the ‘OK’ button whenever you’re done adding a source folder.


  12. This should have been added on your project’s PyDev – PYTHONPATH. Your project tree should look like on the image below.


  13. To test that this works properly, open up your file and Ctrl+Click on the patterns call – it should take you to
  14. To test the site, select your root directory and navigate to Run > Run on your eclipse menu or simply hit Ctrl+F11.

Back to Blog