Setup Google App Engine Development Environment

This tutorial will show how to setup a development environment to work on Google App Engine (GAE) for Python that we learned from developing a Khmer dictionaries site. This procedure tailors for developing with Khmer Unicode using Eclipse and PyDev plugins.

This first part of the series will show how to download and install all necessary software to start developing GAE Python application.

Setup Development Environment

These section will show how to setup and configure the development environment so you can create a Python project.

Download and Install Prerequisite

These steps will show how to download and install all necessary software to start developing GAE Python application.

  1. Download and install Python.
    • Download Python suggest 2.5.4.
    • Then install it to a directory ie. c:\python25. The path will be added so you can type "python" from any directories.
  2. Download and install GAE SDK.
    • Download GAE SDK. Select msi file for Windows. Then install it.
    • Install it by following the installation instruction and choose the install location (ie. c:\Program Files\Google\google_appengine).
    • When the install complete, a path will be added for GAE SDK installation directory so you can execute GAE command line from any directories.
  3. Download and install Eclipse.
    • You will need the Sun JRE 1.5 or above to run Eclipse. You can download the latest Java version at www.java.com.
    • Download Eclipse IDE. Suggest using Eclipse IDE for Java Developer for Windows from here.
    • The internal Windows zip program may not be able to extract the Eclipse zip file because of the long path. Suggest using 7-Zip instead. Download and install 7-Zip.
    • Launch 7-Zip, then unzip Eclipse file to a directory, ie. c:\eclipse.

Now all of the major software is install. You are ready to configure Eclipse.

Install Eclipse Plugins PyDev

After all of the major software is install, we can start configure Eclipse. This instruction is based on Eclipse 3.4. For Eclipse 3.3 see http://code.google.com/appengine/articles/eclipse.html.

  1. Launch Eclipse by double click on Eclipse icon from the unzip directory. Then select the default workspace by clicking OK.
  2. From Eclipse menu, go to Help -> Software Updates.... Then select Available Software tab, click Add sites
  3. Then enter URL: http://pydev.org/updates, then click OK. (see image)
  4. An update list will be populated, check the item "PyDev for Eclipse" then click on "Install..." (see image)
  5. Eclipse will determine what to download. In the next Install dialogue click on Next.
  6. Select "I accept the terms ..." and click Finish.
  7. In the next prompt, click Yes to restart Eclipse.

You also can install Google plugins for GAE and GWT. Go here and follow the direction: http://code.google.com/eclipse/docs/getting_started.html

Configure PyDev

Now you are ready to configure PyDev to point to the correct Python installed earlier so it can work properly. After re-starting Eclipse, do the following:

  1. From Windows menu select Preferences.
  2. In the preferences dialog select the "PyDev" -> "Interpreter - Python"
  3. Click on "New" right to the "Python interpreters" field to add an interpreter
  4. Search for the python.exe from the previous install ie. c:\python25
  5. Click "OK" in the next prompt to accept the pythonpath.
  6. Then click OK in the Preferences window to confirm your changes.

Now you are ready to create a python project. See the next section.

Create and Run Python Project

This section show how to create a new "helloword" project that just output "Hello, World" and run it. Then see the output in the browser.

Create a new helloword project

  1. Change to PyDev perspective by going to Windows menu -> Perspective -> Others, then select PyDev.
  2. Right-click in the Package Explorer and choose New, then select "Pydev project" from the Pydev folder.
  3. Then enter "helloworld" as a project name. See image or right.
  4. Click "Finish", you should see the new project in the Package Explorer window.
  5. Add Python PATH through project property by right click on your new project and choose "Properties".
  6. From the left of the dialog choose the "PyDev - PYTHONPATH" and click on "External Libraries" tab in the right side of the windows. (See image below)
  7. Click on "Add source folder" to add the following six directories below then click OK. Repeat this step for each entry. Change "C:\Program Files\Google\google_appengine" to match where you install GAE SDK.
    C:\Program Files\Google\google_appengine
    C:\Program Files\Google\google_appengine\lib\django
    C:\Program Files\Google\google_appengine\lib\webob
    C:\Program Files\Google\google_appengine\lib\yaml
    C:\Program Files\Google\google_appengine\google\appengine
    C:\Program Files\Google\google_appengine\google\appengine\api
  8. Then click "OK".

Configure and Edit Python files

See more explnation here: http://code.google.com/appengine/docs/python/gettingstarted/helloworld.html

  1. Right click on src under helloworld project, New -> File and enter file
  2. Enter File name: app.yaml, then click Finish.
  3. Double click on the newly created file to edit. Then enter the following and press Ctrl-S to save the file.
    application: helloworld
    version: 1
    runtime: python
    api_version: 1

    handlers:
    - url: /.*
    script: helloworld.py
  4. Create a new Python Module but right click on the project and select New -> Python module and enter Name: helloworld and click Finish.
  5. Then Enter the following content and press Ctrl-S to save the file
    print 'Content-Type: text/plain'
    print ''
    print 'Hello, world!'

Setup Run Environment

This section will setup the Play button so you can click when you want to see the program output from Google App Engine development server.

  1. Go to "Run" menu then> "Open Run Dialog..."
  2. Choose "Python Run" and click icon with the plus sign in the top left of the dialog to add a new launch configuration.
  3. Enter the following information:
    Name: GAE helloworld
    Main Module: [GAE SDK]\dev_appserver.py (ie. D:\Program Files\Google\google_appengine\dev_appserver.py)
  4. Go to the "Arguments" tab and enter the text below to use GAE port of 8080:
    "${workspace_loc:helloworld}/src"
    --port 8080
  5. Click "Apply" to save your changes then click Run.
  6. In the Console view window, you should see red text indicating "Running application helloworld on port 8080"
  7. Now you can browse the output at http://localhost:8080/. You should see the hello world output.

Now you are ready to develop your application. In the next series, we will show you how to handle Khmer Unicode specific setup and output example. See Development on GAE using Khmer Unicode