[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-21。"],[[["\u003cp\u003eThe Python runtime for App Engine's standard environment is specified in the \u003ccode\u003eapp.yaml\u003c/code\u003e file using the format \u003ccode\u003eruntime: python<VERSION>\u003c/code\u003e, where VERSION represents the major and minor Python version numbers.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine automatically updates to new patch versions of Python, but minor version updates (e.g., from 3.7 to 3.8) are not automatic and need manual configuration.\u003c/p\u003e\n"],["\u003cp\u003eDuring deployment, App Engine uses \u003ccode\u003epip\u003c/code\u003e to install dependencies listed in the \u003ccode\u003erequirements.txt\u003c/code\u003e file, and dependency specification using \u003ccode\u003ePipfile\u003c/code\u003e or \u003ccode\u003ePipfile.lock\u003c/code\u003e is not supported.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eentrypoint\u003c/code\u003e field in \u003ccode\u003eapp.yaml\u003c/code\u003e specifies the command to start your app, and if unspecified, App Engine will start the app with \u003ccode\u003egunicorn\u003c/code\u003e if it meets certain conditions, such as having a \u003ccode\u003emain.py\u003c/code\u003e file with a WSGI-compatible object called \u003ccode\u003eapp\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine sets various environment variables like \u003ccode\u003ePORT\u003c/code\u003e, \u003ccode\u003eGAE_APPLICATION\u003c/code\u003e, and \u003ccode\u003eGAE_VERSION\u003c/code\u003e, and allows defining additional custom environment variables within the \u003ccode\u003eapp.yaml\u003c/code\u003e file, excluding overriding the built-in ones.\u003c/p\u003e\n"]]],[],null,["# Python 3 Runtime Environment\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n\u003cbr /\u003e\n\n\nThe Python runtime is the software stack responsible for installing\nyour web service's code and its dependencies and running your App Engine service.\n\nThe Python runtime for App Engine in the standard environment is\ndeclared in the [`app.yaml`](/appengine/docs/standard/python3/configuring-your-app-with-app-yaml)\nfile: \n\n```yaml\nruntime: python\u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e\n```\n\nWhere \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e is the Python `MAJOR` and `MINOR` version numbers. For\nexample, to use the latest Python version, Python 3.13, specify\n`313`.\n\nFor other supported Python versions, and the corresponding Ubuntu version for your\nPython version, see the [Runtime support schedule](/appengine/docs/standard/lifecycle/support-schedule#python).\n\nPython 3 versions\n-----------------\n\nThe latest supported Python version is 3.13. The Python runtime uses the latest stable release of the\nversion that is specified in your `app.yaml` file.\nApp Engine automatically updates to new patch versions,\nbut it does not automatically update the minor version.\n\nFor example, your application might be deployed at Python 3.7.0 and later\nautomatically updated to Python 3.7.1, but it will not be automatically updated\nto the next minor version Python 3.8.0.\n\nTry it for yourself\n-------------------\n\n\nIf you're new to Google Cloud, create an account to evaluate how\nApp Engine performs in real-world\nscenarios. New customers also get $300 in free credits to run, test, and\ndeploy workloads.\n[Try App Engine free](https://console.cloud.google.com/freetrial)\n\nApp Engine runs Python apps in a container secured by gVisor on an\nup-to-date Ubuntu Linux distribution.\n\nDependencies\n------------\n\nDuring deployment, App Engine uses the Python package manager\n[`pip`](http://pip.readthedocs.org/) to install dependencies\ndefined in the [`requirements.txt`](http://pip.readthedocs.org/en/stable/user_guide/#requirements-files)\nmetadata file located in your project's root directory. You do not need to\nupload dependencies as App Engine performs a fresh install.\n\nDependency specification using the `Pipfile`/`Pipfile.lock` standard is\ncurrently not supported and your project must not have these files present.\n\nApplication startup\n-------------------\n\nThe runtime starts your app by running the command you specify in the\n[`entrypoint`](/appengine/docs/standard/reference/app-yaml#entrypoint) field\nin your `app.yaml` file. If you have configured a Gunicorn web server\nentrypoint in the `app.yaml` file, you must also add `gunicorn` to your\n`requirements.txt` file.\n\nThe entrypoint should start a web server that listens\non the port specified by the `PORT` environment variable. For example: \n\n entrypoint: gunicorn -b :$PORT main:app\n\nThe web framework that your app uses is responsible for routing requests to the\nappropriate handlers in your app.\n\nIf your app meets the following requirements, App Engine will start\nyour app with the [`gunicorn`](https://gunicorn.org/) web server if you don't\nspecify the `entrypoint` field:\n\n- The root of your app directory contains a `main.py` file with a\n WSGI-compatible object called `app`.\n\n- Your app does not contain `Pipfile` or `Pipfile.lock` files.\n\nIf you do not specify an entrypoint for the Python 3 runtime, App Engine\nconfigures and starts the default Gunicorn web server.\n| **Note:** The [`default timeout of\n| gunicorn`](https://docs.gunicorn.org/en/stable/settings.html#timeout) is 30 seconds when the `entrypoint` field is specified. Workers silent for more than this many seconds are killed and restarted. If your handler takes more than 30 seconds, you may face `[CRITICAL] WORKER TIMEOUT` error. To ensure that the request successfully completes, based on your use-case, you can use the [`--\n| timeout flag`](https://docs.gunicorn.org/en/stable/settings.html#timeout) in the entrypoint field to increase the timeout.\n\n### Entrypoint best practices\n\n- Ensure the Python module required to run the specified entrypoint in\n `app.yaml` is present in the `requirements.txt` file. Add `gunicorn` to the\n `requirements.txt` file only if a `gunicorn` endpoint is explicitly specified\n in the `app.yaml` file.\n\n- For the best performance, the entrypoint should be lightweight because it runs\n whenever a new instance of your application is created.\n\n- You can use the entrypoint field to tune the performance of your app. For\n example, if you use `gunicorn` as your web server, you can use the\n [`--workers` flag](http://docs.gunicorn.org/en/stable/settings.html#workers)\n in the entrypoint field to configure the number of workers serving your app.\n\n The number of workers you specify should match the\n [instance class](/appengine/docs/standard#instance_classes)\n of your App Engine app:\n\n This guidance serves as a starting point for selecting the\n number of workers. You may need to use a different number of workers\n depending on your app's performance characteristics.\n The example below shows an App Engine deployment that uses two\n `gunicorn` workers for serving apps: \n\n entrypoint: gunicorn -b :$PORT -w 2 main:app\n\n- We recommend that you configure your web server to listen and respond to HTTP\n requests on the port specified by your `$PORT`\n [environment variable](#environment_variables). Using the default port `8080`\n prevents App Engine from using its NGINX layer to compress HTTP\n responses. Note that if you use port `8080`, warnings about\n port `8080` and NGINX will show in your app's log files.\n\n### Other web frameworks\n\nIn addition to Django and Flask, you can use other web frameworks with\nApp Engine, such as\n[`uwsgi`](https://uwsgi-docs.readthedocs.io/en/latest/) and\n[`Tornado`](https://www.tornadoweb.org/en/stable/). The following example shows\nhow to use `uwsgi` with App Engine: \n\n runtime: python39\n entrypoint: uwsgi --http-socket :$PORT --wsgi-file main.py --callable app --master --processes 1 --threads 2\n\n uwsgi==2.0.22\n Flask==3.0.0\n\n\u003cbr /\u003e\n\nEnvironment variables\n---------------------\n\nThe following environment variables are set by the runtime:\n\nYou can\n[define additional environment variables in your `app.yaml` file](/appengine/docs/standard/reference/app-yaml#environment_variables),\nbut the above values cannot be overridden, except for `NODE_ENV`.\n\n\u003cbr /\u003e\n\nHTTPS and forwarding proxies\n----------------------------\n\nApp Engine terminates HTTPS connections at the load balancer and\nforwards requests to your application. Some applications need to determine\nthe original request IP and protocol. The user's IP address is available in\nthe standard `X-Forwarded-For` header. Applications that require this\ninformation should configure their web framework to trust the proxy.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nFilesystem\n----------\n\nThe runtime includes a full filesystem. The filesystem is read-only except for\nthe location `/tmp`, which is a virtual disk storing data in your\nApp Engine instance's RAM.\n\n\u003cbr /\u003e\n\nMetadata server\n---------------\n\nEach instance of your application can use the App Engine metadata server\nto query information about the instance and your project.\n| **Note:** Custom metadata is not supported in the standard environment.\n\nYou can access the metadata server through the following endpoints:\n\n- `http://metadata`\n- `http://metadata.google.internal`\n\nRequests sent to the metadata server must include the request header\n`Metadata-Flavor: Google`. This header indicates that the request was sent with\nthe intention of retrieving metadata values.\n\nThe following table lists the endpoints where you can make HTTP requests for\nspecific metadata:\n\nFor example, to retrieve your project ID, send a request to\n`http://metadata.google.internal/computeMetadata/v1/project/project-id`.\n\n\u003cbr /\u003e"]]