Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
In addition to the Python standard library, the App Engine APIs and tools, the App Engine Python runtime environment includes several third-party libraries that your application can use. Some of these libraries have been customized or reimplemented to run within the App Engine sandbox restrictions. This page documents which libraries are available and how the App Engine implementations differ from the original versions.
Third-party libraries must be specified in app.yaml
, and this configuration is different than in Python 2.5 (see Configuring Libraries for details). The following sample library element from app.yaml
shows how to specify all of the available libraries with the most current version:
libraries: - name: Django version: "1.2" - name: jinja2 version: "2.6" - name: lxml version: "2.3" - name: MarkupSafe version: "0.15" - name: NumPy version: "1.6.1" - name: PIL version: "1.1.7" - name: PyCrypto version: "2.3" - name: SetupTools version: "0.6c11" - name: WebApp2 version: "2.3" - name: WebOb version: "1.1.1" - name: yaml version: "3.10"
Django is a full-featured web application framework for Python. It provides a full stack of interchangable components, including dispatch, views, middleware, and templating components, and many others.
The Django data modeling interface is not compatible with the App Engine datastore. You can use the App Engine data modeling libraries in your Django applications. However, third-party Django applications that use the Django data modeling interface—most notably Django's Admin application—may not work with App Engine directly.
Warning! The App Engine Python 2.7 environment supports version 1.2 only. If you are upgrading to Python 2.7 and currently use Django version 0.96 or 1.0, you must upgrade your application and use version 1.2. See Porting Your Apps from Django .96 to 1.0 for upgrade details.
To use Django in Python 2.7, specify the WSGI application and Django library in app.yaml
:
... handlers: - url: /.* script: main.app # a WSGI application in the main module's global scope libraries: - name: django version: "1.2"
The use_library()
function provided by the google.appengine.dist
package is unavailable in Python 2.7.
Django 1.2 requires that the DJANGO_SETTINGS_MODULE
environment variable be set to the name of your Django settings module, typically 'settings'
, before packages are imported. If your Django settings module is something other than settings.py
, adjust your main.py
file accordingly:
import os # specify the name of your settings module os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings' import django.core.handlers.wsgi app = django.core.handlers.wsgi.WSGIHandler()
The lxml toolkit provides easy-to-use functions for processing XML and HTML using Python. Python 2.7 provides lxml version 2.3.
jinja2 is a template engine for Python. WebApp templates are deprecated in Python 2.7, and jinja2 provides an alternative. The Python 2.7 environment supports jinja2 version 2.6.
MarkupSafe provides a safe string for XML, HTML, and XHTML markup in Python. Python 2.7 supports version 0.15.
Note: enabling this library will make jinja2 template rendering faster.
NumPy provides a number of useful data processing tools. Python 2.7 provides version 1.6.1 of this library.
The Python Imaging Library (PIL) provides image processing functions. Python 2.7 provides version 1.1.7 of this library.
The Python Cryptography Toolkit, also known as PyCrypto, provides cryptography functions such as random number generation. Python 2.7 provides PyCrypto 2.3.
setuptools makes it easier to download, build, install, upgrade, and uninstall Python packages. Python 2.7 supports version 0.6c11.
WebOb is an object-oriented interface for HTTP requests and responses. App Engine uses WebOb as part of the webapp web application framework. The environment provides WebOb 1.1.1.
YAML is a data format for human-readable message serialization. The App Engine Python SDK uses YAML as the format for its configuration files. The environment provides the YAML parsing libraries for Python, PyYAML 3.10.