Registry /
gcp / appengine-python-standard
Install & Compatibility
Where this runs
tested against v3.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 108.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 8.2s · import 0.006s · 105MB
109MB installed
● package 109MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
wrap_wsgi_app
✓ from google.appengine.api import wrap_wsgi_app
Essential middleware for enabling App Engine API calls within your WSGI application.
mail
✓ from google.appengine.api import mail
Provides access to the App Engine Mail API for sending and receiving emails.
urlfetch
✓ from google.appengine.api import urlfetch
Used for fetching URLs, leveraging App Engine's URL Fetch service.
memcache
✓ from google.appengine.api import memcache
For interacting with the App Engine Memcache service.
ndb
✓ from google.cloud import ndb
✗ from google.appengine.ext import ndb
For Python 3, the NDB client library is `google-cloud-ndb`, not `google.appengine.ext.ndb` (which is for Python 2). The `appengine-python-standard` SDK provides the necessary context for `google.cloud.ndb` to function correctly within App Engine Standard.
This quickstart demonstrates a basic Flask application using `appengine-python-standard` to access the App Engine Memcache service. It includes the required `wrap_wsgi_app` middleware call. For deployment, ensure your `app.yaml` includes `app_engine_apis: true` and specifies a Python 3 runtime and an entrypoint (e.g., Gunicorn).
import os
from flask import Flask, request
from google.appengine.api import wrap_wsgi_app, memcache
app = Flask(__name__)
app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
@app.route('/')
def hello():
visits = memcache.incr('visits', initial_value=0)
return f'Hello, App Engine! You have visited this page {visits} times.'
if __name__ == '__main__':
# This is used when running locally. Gunicorn is used for deployment.
# Ensure that `app_engine_apis: true` is set in app.yaml for deployment.
port = int(os.environ.get('PORT', 8080))
app.run(host='127.0.0.1', port=port, debug=True)
Debug
Known issues
breakingMigrating from Python 2.7 to Python 3 on App Engine Standard is a significant undertaking. The Python 3 runtime fundamentally differs, deprecating Python 2.7's bundled services model and requiring the use of standard Python libraries or specific SDKs like `appengine-python-standard`. Frameworks like `webapp2` are not supported, necessitating a switch to WSGI-compatible frameworks like Flask or Django.fixReview comprehensive migration guides provided by Google Cloud. Replace Python 2-specific API calls with `appengine-python-standard` imports or standalone Google Cloud client libraries. Update `app.yaml` configuration to Python 3 standards.
affects: All versions when migrating from App Engine Python 2.7
gotchaTo enable App Engine APIs with this SDK, your `app.yaml` must explicitly include `app_engine_apis: true`, and your WSGI application object (e.g., Flask app) must be wrapped with `google.appengine.api.wrap_wsgi_app()`. Failure to do so will result in API calls failing.fixAdd `app_engine_apis: true` to `app.yaml` and integrate `app.wsgi_app = wrap_wsgi_app(app.wsgi_app)` (or similar for other WSGI apps) into your main application file.
affects: All versions
breakingThe standard Python `cgi` module, previously used for handling CGI requests, has been removed in Python 3.13. Applications relying on this module will break. `appengine-python-standard` v1.1.11 and later address this by using `legacy-cgi` for Python versions above 3.9, but explicit dependency might still be needed for certain setups.fixEnsure `appengine-python-standard` is at v1.1.11 or higher. For applications with direct `cgi` dependencies, explicitly add `legacy-cgi` to `requirements.txt`. Consider migrating away from direct CGI usage to a modern WSGI framework.
affects: v1.1.10 and older on Python 3.13+
gotchaWhen using NDB in Python 3 on App Engine Standard, you must import `ndb` from `google.cloud.ndb` and ensure an NDB client context is active for Datastore operations. The Python 2 `google.appengine.ext.ndb` import is deprecated and will not work.fixUse `from google.cloud import ndb`. When running locally, set `GOOGLE_APPLICATION_CREDENTIALS`. When deployed to App Engine, the context is usually handled automatically, but explicitly using `with client.context():` is good practice.
affects: All versions
deprecatedSeveral `app.yaml` attributes from Python 2.7 are deprecated or unsupported in the Python 3 runtime, including `api_version`, `threadsafe`, `libraries`, `builtins`, and `skip_files`. Using them may lead to deployment errors or unexpected behavior.fixRemove these deprecated attributes from your `app.yaml`. For `skip_files`, use a `.gcloudignore` file. For thread safety, Python 3 apps are assumed to be threadsafe; if not, configure `max_concurrent_requests` to 1.
affects: All versions
gotchaThe Mail API's functionality in Python 3 has evolved. While `appengine-python-standard` re-introduces the Mail API via `google.appengine.api.mail`, earlier migration advice suggested using third-party mail providers due to its initial absence in Python 3. Version 2.0.0 adds SMTP fallback, introducing new environment variables for configuration (`APPE_MAIL_SMTP_HOST`, `APPE_MAIL_SMTP_PORT`, etc.).fixFor applications needing Mail API, use `from google.appengine.api import mail`. If using v2.0.0 for SMTP fallback, configure the relevant environment variables in `app.yaml` as needed.
affects: All versions, especially v2.0.0+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'google.appengine.api'
The 'google.appengine' module is not available in the Python 3 runtime environment.
fixUse the 'appengine-python-standard' library to access App Engine services in Python 3.
ImportError: No module named 'google.appengine.api'
The 'google.appengine' module is specific to the Python 2.7 runtime and is not available in Python 3.
fixMigrate to the 'appengine-python-standard' library for compatibility with Python 3.
ImportError: No module named appengine.api
The 'google.appengine' module is not included in the Python 3 runtime environment.
fixReplace 'google.appengine' imports with the 'appengine-python-standard' library in your Python 3 application.
ModuleNotFoundError: No module named 'google.appengine'
This error commonly occurs when migrating a Python 2 App Engine application to Python 3, as the `google.appengine` modules are not automatically present in the Python 3 standard environment's path and require the `appengine-python-standard` SDK and specific configuration.
fix1. Add `appengine-python-standard>=1.0.0` to your `requirements.txt` file. 2. Add `app_engine_apis: true` to your `app.yaml` file. 3. In your main Python script, wrap your WSGI application with the provided middleware: `from google.appengine.api import wrap_wsgi_app; app.wsgi_app = wrap_wsgi_app(app.wsgi_app)`. 4. Ensure your Google Cloud SDK is up to date by running `gcloud components update`.
ImportError: cannot import name 'ndb' from 'google.appengine.ext'
This error arises when attempting to use the legacy App Engine NDB client library in a Python 3 App Engine standard environment without proper setup, or when implicitly expecting the Python 2 NDB behavior. While `appengine-python-standard` supports legacy NDB, the recommended approach for Python 3 is Cloud NDB, which uses a different import path.
fix1. If continuing to use the legacy App Engine NDB services via `appengine-python-standard`, ensure the `appengine-python-standard` SDK is installed and configured as described for `ModuleNotFoundError`. The import `from google.appengine.ext import ndb` should then work. 2. For new Python 3 development or for migrating, transition to Cloud NDB, which requires installing `google-cloud-ndb` via `pip` and importing with `from google.cloud import ndb`.
Upgrade
Version history
3.0.2latest on PyPI · released Aug 12, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.6 or higher, but less than Python 4.
legacy-cgioptionalRequired for Python versions 3.13 and above to replace the removed standard 'cgi' module, particularly for applications relying on its functionality.