Preparing configuration files for the Python 3 runtime
Stay organized with collectionsSave and categorize content based on your preferences.
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. This file contains information about your app's code, such as the
runtime and the app handlers.
appengine_config.py. The Python 2 runtime uses this file to access
third-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.yamlconfiguration filehas been modified. Remove any fields that are no longer supported and update
other fields as described in the following table.
All applications are presumed to be threadsafe. If your application isn't
threadsafe specify anentrypointconfiguring 1 thread per worker.
For example, when using the F4 instance class:entrypoint: gunicorn -b :$PORT -w 8 --threads 1 main:appSeeentrypoint best practicesfor recommended number of workers for each instance class.
In the Python 2 runtime, you use thescriptfield 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 thescriptfield.
To migrate yourapp.yamlfile to the Python 3 runtime, do
one of the following, depending on whether the file containsstatic handlersas well as script handlers:
If yourapp.yamlfile contains static handlers, do one
of the following to ensure that requests for dynamic content are
routed to your app's script:
Remove allscriptfields. Then add anentrypointfield 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 theentrypointfield. The web server
and your app's web framework are responsible for routing the request
to the correct script.
Replace the value of allscriptfields 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.yamlfile doesnotcontain static
handlers, remove allscriptfields. 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 anentrypointfield to customize thedefault startup behavior.
If yourapp.yamlhas both types of handlers, you can
still remove all the script handlers that would be markedauto, leaving behind the static handlers as well asautohandlers requiring other directives, such as the
admin-only handler in the example below.
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 runtime
uses the standardrequirements.txtfile toinstall dependencies,
including dependencies that use native code.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[[["\u003cp\u003eThe Python 3 runtime on App Engine standard environment requires updates to the \u003ccode\u003eapp.yaml\u003c/code\u003e file, while the \u003ccode\u003eappengine_config.py\u003c/code\u003e file is no longer used.\u003c/p\u003e\n"],["\u003cp\u003eSeveral fields in the \u003ccode\u003eapp.yaml\u003c/code\u003e file are no longer supported in Python 3, including \u003ccode\u003eapi_version\u003c/code\u003e, \u003ccode\u003eapplication_readable\u003c/code\u003e, \u003ccode\u003ebuiltins\u003c/code\u003e, \u003ccode\u003ethreadsafe\u003c/code\u003e, and \u003ccode\u003elibraries\u003c/code\u003e, each having different changes in requirements or methodology.\u003c/p\u003e\n"],["\u003cp\u003eIf using the legacy bundled services, the \u003ccode\u003eapp_engine_apis\u003c/code\u003e field in \u003ccode\u003eapp.yaml\u003c/code\u003e must be set to \u003ccode\u003etrue\u003c/code\u003e, and it enables the use of \u003ccode\u003ehandlers: login\u003c/code\u003e; otherwise, Identity and Access Management (IAM) should be used.\u003c/p\u003e\n"],["\u003cp\u003eIn Python 3, the \u003ccode\u003escript\u003c/code\u003e field in \u003ccode\u003eapp.yaml\u003c/code\u003e handlers is replaced by in-app routing using a web framework like Flask or Django, and the \u003ccode\u003eentrypoint\u003c/code\u003e field is used to start the web server, which will handle the routing.\u003c/p\u003e\n"],["\u003cp\u003eIn the Python 3 runtime, dependencies are installed using the standard \u003ccode\u003erequirements.txt\u003c/code\u003e file instead of the \u003ccode\u003eappengine_config.py\u003c/code\u003e file used in Python 2, meaning the latter file can be removed.\u003c/p\u003e\n"]]],[],null,["# Preparing configuration files for the Python 3 runtime\n\nBefore you can run your app in the Python 3 runtime of the App Engine standard environment, you\nmay need to change some of the configuration files that App Engine uses:\n\n- `app.yaml`. This file contains information about your app's code, such as the\n runtime and the app handlers.\n\n- `appengine_config.py`. The Python 2 runtime uses this file to access\n third-party libraries and provide values for constants and \"hook functions\".\n The Python 3 runtime doesn't use this file.\n\nUpdating `app.yaml`\n-------------------\n\nThe behavior of some fields in your\n[`app.yaml` configuration file](/appengine/docs/standard/reference/app-yaml#entrypoint)\nhas been modified. Remove any fields that are no longer supported and update\nother fields as described in the following table.\n\nIf you use any of the deprecated fields, App Engine returns an error\nwhen you deploy your app.\n\nYou can use the following examples to compare the differences between the\n`app.yaml` files: \n\n### Python 2\n\n```yaml\nruntime: python27\napi_version: 1\nthreadsafe: true\n\nhandlers:\n- url: /\n script: home.app\n\n- url: /index\\.html\n script: home.app\n\n- url: /stylesheets\n static_dir: stylesheets\n\n- url: /(.*\\.(gif|png|jpg))$\n static_files: static/\\1\n upload: static/.*\\.(gif|png|jpg)$\n\n- url: /admin/.*\n script: admin.app\n login: admin\n\n- url: /.*\n script: not_found.app\n```\n\n### Python 3\n\n runtime: python313\n app_engine_apis: true\n\n handlers:\n - url: /stylesheets\n static_dir: stylesheets\n\n - url: /(.*\\.(gif|png|jpg))$\n static_files: static/\\1\n upload: static/.*\\.(gif|png|jpg)$\n\n - url: /admin/.*\n script: auto\n login: admin\n\n| **Note:** For Python 3 the preferred WSGI-compatible web server is `gunicorn`. When you use the optional `entrypoint` field in your [`app.yaml`](/appengine/docs/standard/reference/app-yaml#runtime_and_app_elements) configuration file, the timeout for `gunicorn` defaults to 30 seconds. To set a custom timeout, update the `entrypoint` field: for example, `entrypoint: gunicorn -b :$PORT --timeout=600`. In this case, [make sure you\n| have included `gunicorn`](/appengine/docs/standard/python3/runtime#entrypoint_best_practices) in your `requirements.txt` file.\n\nRemoving `appengine_config.py`\n------------------------------\n\nThe Python 2 runtime in the App Engine standard environment uses the\n[`appengine_config.py`](/appengine/docs/legacy/standard/python/tools/using-libraries-python-27)\nfile.\n\nThis file is ignored in the Python 3 runtime. Instead, the Python 3 runtime\nuses the standard `requirements.txt` file to\n[install dependencies](/appengine/docs/standard/python3/specifying-dependencies),\nincluding dependencies that use native code."]]