Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Sie können benutzerdefinierte Laufzeiten dazu verwenden, einer Python-Anwendung, die in einer flexiblen Umgebung ausgeführt wird, zusätzliche Funktionen hinzuzufügen. Zur Konfiguration einer benutzerdefinierten Laufzeit ersetzen Sie diese Zeile in der Datei app.yaml:
runtime:python
durch diese Zeile:
runtime:custom
Sie müssen außerdem ein Basis-Image angeben, indem Sie ein Dockerfile in demselben Verzeichnis hinzufügen, in dem sich die Datei app.yaml befindet.
Informationen zum Definieren eines Dockerfiles in einer benutzerdefinierten Laufzeit finden Sie in der Dokumentation zu benutzerdefinierten Laufzeiten.
Systemdiagnose
Standardmäßig erhalten alle Programme, die in der flexiblen Umgebung ausgeführt werden, Systemdiagnoseanfragen.
Wenn ein Basis-Image die Systemdiagnose unterstützt, müssen Sie keinen zusätzlichen Code schreiben. Ist dies nicht der Fall, müssen Sie die Systemdiagnosen deaktivieren oder einen eigenen Programmcode zur Verarbeitung von Systemdiagnoseanfragen schreiben.
Python-Version auswählen
In der python-Laufzeit sind Python 2.7.12 und Python 3.6.10 vorinstalliert. Sie können das Dockerfile anpassen, um bei Bedarf andere Versionen oder alternative Interpreter zu installieren.
Bei der Erstellung der virtuellen Umgebung können Sie angeben, ob im Dockerfile der Anwendung Python 2 oder Python 3 verwendet werden soll:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-19 (UTC)."],[[["\u003cp\u003eCustom runtimes allow adding extra features to Python apps in the flexible environment by replacing \u003ccode\u003eruntime: python\u003c/code\u003e with \u003ccode\u003eruntime: custom\u003c/code\u003e in the \u003ccode\u003eapp.yaml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eA Dockerfile must be included in the same directory as the \u003ccode\u003eapp.yaml\u003c/code\u003e file to specify a base image when using custom runtimes.\u003c/p\u003e\n"],["\u003cp\u003eBy default, apps in the flexible environment have health check requests; base images that don't support it must either disable them or implement custom code to handle them.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epython\u003c/code\u003e runtime has Python 2.7.12 and Python 3.6.10, but you can install other versions by customizing the \u003ccode\u003eDockerfile\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIn your \u003ccode\u003eDockerfile\u003c/code\u003e you can specify whether to use Python 2 or 3 by adding the corresponding line to your virtual environment.\u003c/p\u003e\n"]]],[],null,["# Customizing the Python runtime\n\nYou can use [custom runtimes](/appengine/docs/flexible/custom-runtimes) to add\nadditional functionality to a Python app running in the flexible environment. To configure\na custom runtime, you replace this line in your `app.yaml` file: \n\n runtime: python\n\nwith this line: \n\n runtime: custom\n\nYou must also [specify a base image](/appengine/docs/flexible/custom-runtimes/build#base)\nby adding a Dockerfile in the same directory that contains the `app.yaml` file.\n\nVisit the [Custom runtimes](/appengine/docs/flexible/custom-runtimes)\ndocumentation to learn how to define a Dockerfile in a custom runtime.\n\nHealth Checking\n---------------\n\nBy default, all programs running in the flexible environment receive [health check requests](/appengine/docs/flexible/custom-runtimes#health_check_requests).\nIf a base image supports health checking, you don't need to write any additional code. If it does not, you will need\nto disable health checks, or write your own code to handle health check requests.\n\nSelecting the Python version\n----------------------------\n\nThe `python` runtime has [Python 2.7.12](https://www.python.org/downloads/release/python-2712/) and [Python 3.6.10](https://www.python.org/downloads/release/python-3610/) pre-installed. You can customize the `Dockerfile` to install other versions or alternative interpreters if needed.\n\nYou can specify a whether to use Python 2 or Python 3 in your application's `Dockerfile` when creating the virtual environment: \n\n # Python 3\n RUN venv /env -p python3.7\n\n # Python 2 (implicit)\n RUN virtualenv /env\n\n # Python 2 (explicit)\n RUN virtualenv /env -p python2.7"]]