Python 3.8 is now generally available.

Differences between the Python 2 and Python 3 runtimes

The Python 3 runtime is built around three core ideas:

  • Your app uses the latest version of the open source Python interpreter provided by the Python Software Foundation.
  • You can use Python's rich ecosystem of packages and frameworks in your app, including those that use C code, by declaring dependencies in a requirements.txt file.
  • You don't need specialized, platform-specific knowledge to develop on App Engine.

The overall goal is that your development should be a fully idiomatic experience, and your app should be fully portable and run in any standard Python environment. You write a standard Python app, not an App Engine Python app. As part of this shift, you no longer use bundled App Engine APIs and services for your app's core functionality. Instead, you use Google Cloud APIs and services or third-party APIs and services.

No bundled App Engine services in the Python 3 runtime

Starting with the Python 3 runtime, the App Engine standard environment no longer includes bundled App Engine services such as Memcache and Task Queues. Instead, Google Cloud provides standalone products that are equivalent to most of the bundled services in the Python 2 runtime. For the bundled services that are not available as separate products in Google Cloud, such as image processing, search, and messaging, you can use third-party providers or other workarounds as suggested in the migration guide.

Other differences between the two runtimes

The following sections highlight additional differences between the Python 2 and Python 3 runtimes.

Configuration files

Before you can run your app in the Python 3 runtime of the App Engine standard environment, you may need to change some of the configuration files that App Engine uses:

  • app.yaml. The behavior of some fields in your app.yaml configuration file has been modified. Remove any deprecated fields and update other fields as described in the migration guide.

  • appengine_config.py. The Python 2 runtime uses this file to install client libraries and provide values for constants and "hook functions". The Python 3 runtime doesn't use this file.

    Instead, the Python 3 runtime uses the standard requirements.txt file to install dependencies, including dependencies that use native code. For more information, see Specifying Dependencies in the Python 3 runtime.

Web framework required to route requests for dynamic content

In the Python 2 runtime, you can create URL handlers in the app.yaml file to specify which app to run when a specific URL or URL pattern is requested.

In the Python 3 runtime, your app needs to use a web framework such as Flask or Django to route requests for dynamic content instead of using URL handlers in app.yaml. For static content, you can continue to create URL handlers in your app's app.yaml file.

Testing

We recommend that you use a testing approach that is idiomatic to Python rather than being dependent on dev_appserver. For example, you might use venv to create an isolated local Python 3 environment. Any standard Python testing framework can be used to write your unit, integration, and system tests. You might also consider setting up development versions of your services or use the local emulators that are available for many Google Cloud products.

As an optional feature for those who do choose to use it, we are offering an alpha version of an updated dev_appserver which supports Python 3. Please see Using the Local Development Server for more information on this option.

Deploying

Deployments via appcfg.py are not supported for Python 3. Use the gcloud command line tool to deploy your app.

Migrating from Python 2 to Python 3

For full details on migrating to the Python 3 runtime, see Migrating to the Python 3 standard runtime.