Configuring Eclipse on Windows to Use With Google App Engine

The post "Configuring Eclipse on Windows to Use With Google App Engine" on Google has not been updated since 2008. Here is the updated version for Eclipse 3.7 (Indigo).

Before you start, download and install the following components:

Installing PyDev plugin

  • Start Eclipse
  • Help > Install New Software…
  • Add PyDev update site by clicking Add…
    • Choose a name (e.g. "pydev").
    • Enter "http://pydev.org/updates/" in the URL field.
    • Click OK.
  • Select PyDev in the list.

  • Click Next, Next, Accept the terms, Finish.
  • Confirm that you trust certificate from Aptana Pydev
  • Restart Eclipse

Configuring PyDev

  • Go Window > Preferences
  • Select PyDev > Interpreter – Python
  • Click Auto Config.

  • Click OK

PyDev Perspective

Switch to PyDev perspective:

  • Window > Open Perspective > Other… > PyDev
  • Click OK

Hello World!

Let's create new project for Hello World application.

  • File > New > Project…
  • PyDev > PyDev Google App Engine Project
  • Next
  • Browse and select path to Google App Engine
  • Click OK

Source Code File

  • Create file: File > New > PyDev Module
  • Specify name – "helloworld"
  • Click Finish
  • Paste the following code into the file:
import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello World!')

app = webapp2.WSGIApplication([('/', MainPage)],
                              debug=True)

Configuration file

  • Create file: File > New > File
  • Specify file name – app.yaml
  • Click Finish
  • Paste the following text:
application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: helloworld.app

Run configuration

  • Run > Run configurations…
  • Right click on PyDev Google App Run, select New
  • Specify Project – "helloworld", and the name of the configuration.
  • Specify full file name dev_appserver.py in the Google App Engine folder:
    e.g. "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py"

  • On the tab "Arguments", in the text area "Program arguments" specify port and the path to the source files:

  • Click Apply and Close

Run!

  • Now we can start helloworld: Run > Run (or simply Ctrl+F11)

Shortcut to localhost:9999

To make access to your new cool site simpler, you can create an internet shortcut to the URL http://localhost:9999 in the src folder on the disk, and refresh project (by selecting src in the Package Explorer and hitting F5).

Have fun :)