Testing and deploying your upgraded app in Python 3

Region ID

TheREGION_ID is an abbreviated code that Google assignsbased on the region you select when you create your app. The code does notcorrespond to a country or province, even though some region IDs may appearsimilar to commonly used country and province codes. For apps created after February 2020,REGION_ID.r is included in App Engine URLs. For existing apps created before this date, the region ID is optional in the URL.

Learn moreabout region IDs.

After you upgrade your app to be compatible with both Python 2 and Python 3:

  1. Test the app in a local Python 3 environment.

  2. Deploy and test in App Engine withoutshifting traffic to your app.

  3. Migrate traffic to your app.

You may need to spend significant time fixing compatibility issues that aren'tvisible until you run your upgraded app in a Python 3 environment.

To avoid using production data and Google Cloud quota during testing, you canuse the following emulators:

Other Google Cloud services such as Cloud Storage andMemorystore don't provide emulators.

Testing locally

To test your app's functionality before deploying, follow the instructions forrunning locallyin the Python 3 runtime.

Testing on App Engine before shifting traffic

Before routing traffic to your upgraded Python app, deploy the app to theApp Engine Python 3 runtime for another round of testing. For example,to test your app'sdefault service:

  1. Make sure you'veupdated the app's configuration files forcompatibility with the Python 3 runtime.

    Don't change environment variables that send requests to emulators ortest databases until you're ready toshift traffic to your app.

  2. Deploy your new version, but prevent traffic from automatically routingto the new version:

    gcloudappdeploy--no-promote

  3. Access your new version by navigating to the following URL:

    https://VERSION_ID-dot-default-dot-PROJECT_ID.REGION_ID.r.appspot.com

    Note: You can find the version ID in theGoogle Cloud console,or specify one when you deploy with the--version flag. The gcloud CLIalso outputs the version ID when you deploy.

Now you can test your new version in the App Engine runtimeenvironment. You can debug your application by viewing its logs. For moreinformation, seeWriting Application Logs.

Requests sent tohttps://PROJECT_ID.REGION_ID.r.appspot.comare routed to the version previously configured to receive traffic.

To test new versions of other services, follow the same process, but replacedefault in the URL with your service's name:

https://VERSION-dot-SERVICE-dot-PROJECT_ID.REGION_ID.r.appspot.com

For more information about targeting specific services and versions, seeHow Requests are Routed.

Migrating traffic to your app

When you're ready to send traffic to the new version:

  1. Update environment variables in yourapp.yaml file to send requests to yourproduction databases and other services instead of any emulators or testdata you were using.

  2. Prevent traffic being automatically routed to your new version upon deployment:

    gcloudappdeploy--no-promote

  3. When you've confirmed that your app is interacting with your production databasesand datastores, use the Google Cloud console to migrate traffic:

    Manage versions

    Select the latest version of your upgraded app and clickMigrate traffic.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.