Preparing configuration files for the Python 3 runtime

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

  • app.yaml. This file contains information about your app's code, such as theruntime and the app handlers.

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

Updatingapp.yaml

The behavior of some fields in yourapp.yaml configuration filehas been modified. Remove any fields that are no longer supported and updateother fields as described in the following table.

FieldChange typeDescription
app_engine_apisApplicable to Python 3 onlyRequired to be set totrue if you want to access thelegacy bundled services for Python 3.
api_version
application_readable
builtins
No longer supportedNot applicable in the Python 3 runtime.
threadsafeNo longer supportedAll applications are presumed to be threadsafe. If your application isn't threadsafe specify anentrypoint configuring 1 thread per worker.

For example, when using the F4 instance class:
entrypoint: gunicorn -b :$PORT -w 8 --threads 1 main:app

Seeentrypoint best practices for recommended number of workers for each instance class.
librariesNo longer supported Use therequirements.txt file todeclare dependencies and install client libraries.
handlers: loginSupported ifapp_engine_apis istrue If you are not using the legacy bundled services for Python 3, useIdentity and Access Management (IAM) for user management.
handlers: scriptModifiedIn the Python 2 runtime, you use thescript field to route incoming requests to your app's script.

In the Python 3 runtime, you are required to use a web framework with in-app routing (such as Flask or Django) instead of using thescript field.

To migrate yourapp.yaml file to the Python 3 runtime, do one of the following, depending on whether the file containsstatic handlers as well as script handlers:

  • If yourapp.yaml file contains static handlers, do one of the following to ensure that requests for dynamic content are routed to your app's script:
    • Remove allscript fields. Then add anentrypoint field to start a web server that runs your app. Requests that don't match any of your static handers will be directed to the web server you specified in theentrypoint field. The web server and your app's web framework are responsible for routing the request to the correct script.
    • Replace the value of allscript fields withauto. App Engine will automatically run your app in a web server (assuming your app meetsa few requirements), and all requests that match a script handler will be directed to the web server. The web server and your app's web framework are responsible for routing the request to the correct script.
    • If yourapp.yaml file doesnot contain static handlers, remove allscript fields. All requests to your app will be directed to your app's web server, and your app's framework will route the request to the correct script. You can optionally add anentrypoint field to customize thedefault startup behavior. If yourapp.yaml has both types of handlers, you can still remove all the script handlers that would be markedauto, leaving behind the static handlers as well asauto handlers requiring other directives, such as the admin-only handler in the example below.

Static file handling remains unchanged.

If you use any of the deprecated fields, App Engine returns an errorwhen you deploy your app.

You can use the following examples to compare the differences between theapp.yaml files:

Python 2

runtime:python27api_version:1threadsafe:truehandlers:-url:/script:home.app-url:/index\.htmlscript:home.app-url:/stylesheetsstatic_dir:stylesheets-url:/(.*\.(gif|png|jpg))$static_files:static/\1upload:static/.*\.(gif|png|jpg)$-url:/admin/.*script:admin.applogin:admin-url:/.*script:not_found.app

Python 3

runtime:python314app_engine_apis:truehandlers:-url:/stylesheetsstatic_dir:stylesheets-url:/(.*\.(gif|png|jpg))$static_files:static/\1upload:static/.*\.(gif|png|jpg)$-url:/admin/.*script:autologin:admin
Note: For Python 3 the preferred WSGI-compatible web server isgunicorn.When you use the optionalentrypoint field in yourapp.yamlconfiguration file, the timeout forgunicorn defaults to 30 seconds. To seta custom timeout, update theentrypoint field: for example,entrypoint: gunicorn -b :$PORT --timeout=600. In this case,make sure youhave includedgunicornin yourrequirements.txt file.

Removingappengine_config.py

The Python 2 runtime in the App Engine standard environment uses theappengine_config.pyfile.

This file is ignored in the Python 3 runtime. Instead, the Python 3 runtimeuses the standardrequirements.txt file toinstall dependencies,including dependencies that use native code.

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.