REGION_ID is an abbreviated code that Google assigns
based on the region you select when you create your app. The code does not
correspond to a country or province, even though some region IDs may appear
similar to commonly used country and province codes. Including
REGION_ID.r in App Engine URLs is optional for
existing apps and will soon be required for all new apps.
To ensure a smooth transition, we are slowly updating App Engine to use region IDs. If we haven't updated your Google Cloud project yet, you won't see a region ID for your app. Since the ID is optional for existing apps, you don't need to update URLs or make other changes once the region ID is available for your existing apps.
Learn more about region IDs.
Get started with local development and debugging with Eclipse and the PyDev plugins. This configuration allows you to run your App Engine app locally in a debug mode and use Eclipse’s Debug perspective to set breakpoints and step through your code. The PyDev plugins provide helper functionality for working with App Engine, including creating starter projects and deploying apps.
Before you begin
- Install Python 2.7 if you do not already have Python installed. Not sure?
- From the Optional section of the SDK download page, install the original App Engine SDK for Python.
Check your version of Python
To check which version of Python that you have installed, run the following command:
- Install the Eclipse Installer.
When the installation finishes, click Launch.
When Eclipse launches, specify a workspace location or accept the default.
After you install Eclipse, you should install the PyDev plugin that allows you to use Eclipse as a Python IDE.
- In Eclipse, click Help > Eclipse Marketplace.
In the Find field, specify "PyDev".
Click Install and complete the installation wizard.
Restart Eclipse when prompted.
Configuring your project
Create a new project: Click File > New > Project.
On the Select a wizard page, select PyDev Google App Engine Project.
On the PyDev Project page, name the project. Then, let Eclipse configure the default interpreter by clicking Please configure an interpreter before proceeding.
If Eclipse did not find a Python 2.7 interpreter, click the Click here to configure an interpreter not listed link to configure the interpreter.
On the Google App Engine page, click Browse and locate the directory where you installed the App Engine SDK. Where is it?
Click Next to continue to configure a basic project or click Finish to start with a blank project.
If you are configuring a project, specify the project ID. To view your project ID, go to the Cloud Console. If you have not yet registered a project, you can specify a temporary name that will be inserted into the project’s
app.yamlfile. You can change this name later if necessary.
Choose a starter template. Recommended: Use the Hello World template to generate an
app.yamlfile and a simple Python script. You can later develop using your choice of frameworks, such as Flask or Django.
Default location of the SDK
If you installed the SDK with the Google App Engine launcher, you are
prompted to create symlinks when the launcher starts. If you created
symlinks, the default location is:
/usr/local/google_appengineIf you did not create symlinks, the default location is:
- The location is where you extracted the SDK zip file that you downloaded.
C:\Program Files (x86)\Google\google_appengine\
Importing libraries for Eclipse to recognize
After you set up a project, you might choose a library that your code will rely on. You will need to import the library into your project and configure your project to load that library, but you will also need to instruct Eclipse to use that library.
To have Eclipse recognize your imported library:
- Import the library to your project.
- Edit your Eclipse project’s properties: Right-click the project and select Properties.
- Select PyDev - PYTHONPATH in the navigation pane of the dialog.
- If you manage your libraries in a child folder of your project, such as `lib`, click Add source folder.
Eclipse now adds your specified libraries onto the Python path for resolving imports.
Launching your app in debug mode
Running your app in debug mode in Eclipse allows you to set breakpoints in your code. When those lines are executed, processing pauses temporarily, allowing you to inspect your code and step through the execution. This functionality is extremely helpful during development of your app.
Setting up a debug configuration
The first time you launch your app in debug mode, it will create a debug configuration that you can execute later or modify to add parameters for your build.
Right-click your project name in the project explorer and select Debug As > PyDev: Google App Run.
The console view should open and display the system output of the development server, which includes the URLs that your app is running.
Verify that your app is running by visiting the URL shown in the console. By default, the app runs from http://localhost:8080. If you used the Hello World starter template, you should see "Hello, world!" printed to the browser.
Debug mode is now running within Eclipse. You also created a Debug configuration that you can run again later if you leave Eclipse or need to stop and restart the debugger.
Setting a breakpoint to step through your code
Now that you have the debugger running, you can set breakpoints and use them to step through your code execution.
Open a file in your Eclipse project, such as the
helloworld.pyfile if you are using the starter template.
Right-click the line number next to the code where you want to set a breakpoint and select Add Breakpoint.
A green circle appears on the line where you set the breakpoint.
Return to the browser and open the URL that will run the line where you set the breakpoint. Eclipse asks you to switch to the Debug perspective when the breakpoint is triggered.
If you are prompted to switch to the Debug perspective, click Yes. This perspective provides a debugging-specific view of your code, including the Variables view.
In the Variables viewer, you can inspect the objects and variables that are currently defined in your code.
The menu bar buttons provide the following controls:
- Continues execution until the next breakpoint is encountered or execution finishes.
- Step into lower level code, such as into a method.
- Step line by line in the current code rather than going into lower level code.
- Step return to higher level code. If you step into lower level code, you might choose to return back to the higher level code before that lower level code finishes its execution to return you back to the calling code.
- Stop the process.
- Skip remaining breakpoints.
Click the continue icon () to continue process and allow the development server to send a simple "Hello, World!" response to the browser.
To switch back to the PyDev perspective after you are finished debugging, choose Window > Perspective > Open Perspective and choose Pydev. Or, click the PyDev icon in the top right corner of Eclipse:
Deploying your app from Eclipse
The PyDev plugin for Eclipse allows you to deploy your app from your workspace.
Use the Google Cloud Console to setup your Google Cloud project:
Either select or create a Cloud project and ensure that it includes an App Engine application:
The Dashboard opens if an App Engine application already exists in your project. Otherwise, you are prompted to choose the region where you want your App Engine application located.
Tip: Your project's ID becomes part of your app's URL, for example,
In Eclipse, edit your
app.yamlfile and change the value of the
applicationelement to your Cloud project ID.
In the PyDev Package Explorer or Project Explorer view, right-click the project folder and choose PyDev Google App Engine > Upload.
If this is your first time running the App Engine SDK management commands, you will be prompted to authorize the SDK to grant access to the tool to modify your App Engine applications. Click Allow.
You can close the browser window when it says "The authentication flow has completed" and return to Eclipse.
Confirm that your application uploads successfully in the Manage Google App Engine dialog:
https://PROJECT_ID.REGION_ID.r.appspot.comand you should see your application serving traffic.
Now that you have a development environment set up, learn to develop and deploy apps in the Cloud Console.