Using Third Party Libraries In Google App Engine

September 6, 2017

There are 2 ways to include libraries in Google App Engine.

libraries: directive in app.yaml

Using libraries: directive in app.yaml to request a library.

libraries:
- name: PIL
  version: "1.1.7"
- name: lxml
  version: "latest"

There are less than 30 built-in libraries supported.

Install any third-party library

In you project directory, create a lib directory to store third party libraries.

mkdir lib

Use pip with -t lib flag to install libraries into the lib directory.

pip install -t lib <library_name>

Create appengine_config.py in the project directory with the following code.

# appengine_config.py
from google.appengine.ext import vendor

# Add any libraries install in the "lib" folder.
vendor.add('lib')

Notes: becareful to avoid using libraries which read/write to local files due to performance impact (Google App Engine doesn’t really have local files, where file read/write is actually done over the network to Google Cloud Storage).

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.