The Python 3 runtime is the software stack responsible for installing your web service's code and its dependencies and running your service.
The Python 3 runtime for App Engine in the standard environment is
declared in the
Python 3 versions
The Python 3 runtime supports Python 3.7, Python 3.8, and Python 3.9,
and it uses the latest stable release of the version that is specified in your
App Engine automatically updates to new patch release versions,
but it will not automatically update the minor version.
For example, your application might be deployed at Python 3.7.0 and later automatically updated to Python 3.7.1, but it will not be automatically updated to the next minor version Python 3.8.0.
Try it for yourself
If you're new to Google Cloud, create an account to evaluate how App Engine performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.Try App Engine free
During deployment, App Engine uses the Python package manager
pip to install dependencies
defined in the
metadata file located in your project's root directory. You do not need to
upload dependencies as App Engine performs a fresh install.
Dependency specification using the
Pipfile.lock standard is
currently not supported and your project must not have these files present.
The runtime starts your app by running the command you specify in the
app.yaml file. The entrypoint should start a web server that listens
on the port specified by the
PORT environment variable. For example:
entrypoint: gunicorn -b :$PORT main:app
The web framework that your app uses is responsible for routing requests to the appropriate handlers in your app.
If your app meets the following requirements, App Engine will start
your app with the
gunicorn web server if you don't
The root of your app directory contains a
main.pyfile with a WSGI-compatible object called
Your app does not contain
App Engine will also automatically add the
gunicorn to your
requirements.txt file if you don't specify the
Entrypoint best practices
Do not include
requirements.txtfile unless you are specifying the entrypoint.
For the best performance, the entrypoint should be lightweight because it runs whenever a new instance of your application is created.
You can use the entrypoint field to tune the performance of your app. For example, if you use
gunicornas your web server, you can use the
--workersflag in the entrypoint field to configure the number of workers serving your app.
The number of workers you specify should match the instance class of your App Engine app:
Instance class Workers F1 1 F2 2 F4 4 F4_1G 8 B1 1 B2 2 B4 4 B4_1G 8 B8 8
This guidance serves as a starting point for selecting the number of workers. You may need to use a different number of workers depending on your app's performance characteristics. The example below shows an App Engine deployment that uses two
gunicornworkers for serving apps:
entrypoint: gunicorn -b :8080 -w 2 main:app
Other web frameworks
runtime: python39 entrypoint: uwsgi --http-socket :8080 --wsgi-file main.py --callable app --master --processes 1 --threads 2
The following environment variables are set by the runtime:
||The ID of your App Engine application. This ID is prefixed with 'region code~' such as 'e~' for applications deployed in Europe.|
||The ID of the current deployment.|
||The App Engine environment. Set to
||The ID of the instance on which your service is currently running.|
||The amount of memory available to the application process, in MB.|
||The runtime specified in your
||The service name specified in your
||The current version label of your service.|
||The Cloud project ID associated with your application.|
||The port that receives HTTP requests.|
define additional environment variables in your
but the above values cannot be overridden.
HTTPS and forwarding proxies
App Engine terminates HTTPS connections at the load balancer and
forwards requests to your application. Some applications need to determine
the original request IP and protocol. The user's IP address is available in
X-Forwarded-For header. Applications that require this
information should configure their web framework to trust the proxy.
The runtime includes a full filesystem. The filesystem is read-only except for
/tmp, which is a virtual disk storing data in your
App Engine instance's RAM.
Each instance of your application can use the App Engine metadata server to query information about the instance and your project.
You can access the metadata server through the following endpoints:
Requests sent to the metadata server must include the request header
Metadata-Flavor: Google. This header indicates that the request was sent with
the intention of retrieving metadata values.
The following table lists the endpoints where you can make HTTP requests for specific metadata:
||The project number assigned to your project.|
||The project ID assigned to your project.|
||The zone the instance is running in.|
||The default service account email assigned to your project.|
||Lists all the default service accounts for your project.|
||Lists all the supported scopes for the default service accounts.|
||Returns the auth token that can be used to authenticate your application to other Google Cloud APIs.|
For example, to retrieve your project ID, send a request to