简体   繁体   中英

Installing usual libraries inside Google App Engine

How should I install (or where should I put and organize) usual python libraries in Google App Engine.

Some libraries require to be installed using setuptools. How can I install that libraries.

You need to unpack the libraries into a subdirectory of your app, and add the library directory to the Python path in your request handler module. Any steps required by setup scripts, you'll have to execute manually, but there generally aren't any unless the library bundles a native module (which aren't supported on App Engine anyway).

If your library contains many files, it's possible to zip them and use zipimport, but that's somewhat more complex, and has performance implications.

For example, suppose you put a library in lib/mylibrary, under your app's directory. In your request handler module, add the following before any of your other imports:

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "lib/mylibrary"))

(Note that this assumes that your request handler is in the root directory of your app.)

Most of them can be installed using the pip .

Follow 3 first points from the Google wiki .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM