简体   繁体   English

在Google App Engine中安装常用库

[英]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. 我应该如何在Google App Engine中安装(或者我应该在哪里放置和组织)常用的python库。

Some libraries require to be installed using setuptools. 某些库需要使用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. 您需要将库解压缩到应用程序的子目录中,并将库目录添加到请求处理程序模块中的Python路径中。 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). 设置脚本所需的任何步骤,您都必须手动执行,但除非库捆绑了本机模块(无论如何都不支持App Engine),因此通常不会执行任何步骤。

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. 如果您的库包含许多文件,则可以将它们压缩并使用zipimport,但这有点复杂,并且具有性能影响。

For example, suppose you put a library in lib/mylibrary, under your app's directory. 例如,假设您将库放在应用程序目录下的lib / mylibrary中。 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 . 关注Google维基的 3个第一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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