Using Third Party Libraries In Google App Engine

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.pyfrom 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).

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.