Migrating to the Python 3 standard runtime

Starting on January 1, 2020, the Python community will no longer update,
fix bugs, or patch security issues for Python 2.7. We recommend that you migrate
apps that are still running in the Python 2 runtime of the App Engine standard
environment to the Python 3 runtime as soon as possible. For more information,
see Python 2 support on Google Cloud.

Key differences between the Python 2 and Python 3 runtimes

Most of the changes you need to make during the migration come from the
following differences between the Python 2 and Python 3 runtimes:

Compatibility issues between Python 2 and Python 3

When Python 3 was first released in 2008,
several backward incompatible changes
were introduced to the language. Some of these changes require only minor updates
to your code, such as changing the print statement to a print() function.
Other changes may require significant updates to your code, such as updating
the way that you handle binary data, text, and strings.

Many popular open source libraries, including the Python standard libraries,
also changed when they moved from Python 2 to Python 3.

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 this migration guide.

Removing the bundled App Engine services enables the Python 3 runtime to
support a fully idiomatic Python development experience. In the Python 3
runtime, you write a standard Python app that is fully portable and can run in
any standard Python environment, including App Engine.

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.

Overview of the migration process

We recommend the following incremental approach to the migration, in which you
maintain a functioning and testable application throughout the process: