Deploying a Python App

This page shows you how to use the appcfg command to deploy your app. The appcfg tool is included with the App Engine Python SDK.

Before you begin

Using a proxy

If you'll be running appcfg on a system which uses an HTTP(S) proxy, set environment variables so that the tool can communicate via the proxy.

Windows

set HTTP_PROXY=http://cache.example.com:3128
set HTTPS_PROXY=http://cache.example.com:3128

Mac / Linux

export http_proxy="http://cache.example.com:3128"
export https_proxy="http://cache.example.com:3128"

Deploying an app

After you deploy, your application runs at the URL https://<YOUR-PROJECT-ID>.appspot.com.

To upload your application files, run the appcfg.py command with the update action and the name of your application's root directory. The root directory must contain the app.yaml file for the application.

appcfg.py update myapp/

The tool will automatically use the application ID from the app.yaml file. However, many of our sample applications omit application: from the app.yaml file, as well as version: so you will need to specify a Console project ID as the application ID and the version of your choice when deploying them:

appcfg.py -A <YOUR_PROJECT_ID> -V v1 update myapp/

If your app is factored into more than one service, you can specify which services should be updated.

  • If you are updating the default service, it must come first in the list.
  • If you are uploading the app for the first time, the default service must be included.
cd myapp
appcfg.py update app.yaml mod1.yaml mod2.yaml

You will receive verification via the command line as each service is successfully deployed.

Updating indexes

If your app's index.yaml file defines an index that doesn't yet exist, App Engine will create it after you upload your app. This process may take a while, and any query that requires the index will raise an exception until the index is built.

To prevent this:

  1. Give the app a new version number in app.yaml.
  2. In the Cloud Platform Console, check the status of the app's indexes.
  3. Once the index has been built, manually update the default version in the Cloud Platform Console.

Alternatively:

  1. Upload the index.yaml configuration before uploading the app:

    appcfg.py update_indexes myapp/
    
  2. In the Cloud Platform Console, check the status of the app's indexes.

  3. Once the index has been built, upload your app.

Troubleshooting

The following are common error messages that you might encounter:

Too Many Versions (403)
App Engine has a limit on the number of deployed versions of your application. These differ for free applications and deployed applications. You can use the Cloud Platform Console to delete an older version and then upload your latest code.
You do not have permission to modify this app (403)
This can occur when the account that you are authenticated as does not have permission to deploy to the application ID that is specified in your command or in your app.yaml. Check your application ID is accurate and matches the value of your Cloud Platform Console project ID. Next, check the project permissions in the console and verify that your account is listed with a sufficient permission level to allow for deploying apps. If the account permission and project ID appear correct, you can try to force a reauthentication of your SDK by removing the .appcfg_oauth2_tokens file from your home directory and retry the deployment commands.

What's next

Send feedback about...