简体   繁体   English

Google App Engine,既不支持urllib3也不支持请求?

[英]Google App Engine, are neither urllib3 nor requests supported?

I keep getting the following error when I deploy my google app: 部署我的谷歌应用程序时,我不断收到以下错误:

ERROR: (gcloud.app.deploy) An error occurred while parsing file: [/Users/app.yaml]the library "requests" is not supported 错误:(gcloud.app.deploy)解析文件时发生错误:[/ Users / app.yaml]库“ requests”不受支持

I have changed it to urllib3, but still get the same error. 我已将其更改为urllib3,但仍会出现相同的错误。 Following is the app.yaml: 以下是app.yaml:

# entrypoint: main.py
# env: flex
# runtime: python

runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /static
  static_dir: static
- url: /.*
  script: main.app

libraries:
  - name: ssl
    version: latest
  - name: lxml
    version: latest
  - name: urllib3
    version: latest
  - name: flask
    version: latest

And the invocation of the library: 并调用库:

# from requests import get as rget 
from urllib3 import PoolManager
http = PoolManager()
query = some_query
# page = rget(query)
page = http.request('GET',query)

I can't seem to figure out what the issue could be. 我似乎无法弄清楚问题是什么。 I have seen previous stack overflow answers which ask me to pip install in the lib, and add it to requirement.txt too, but none of these seem to make a difference. 我已经看到了以前的堆栈溢出答案,这些答案要求我在lib中进行pip安装,并将其也添加到require.txt中,但是这些似乎都没有什么不同。

Is there any other library that does exactly the same but is natively supported by google app engine ? 有没有其他库完全相同但谷歌应用引擎原生支持?

App Engine supports third party libraries in two ways in the standard Python 2.7 environment. App Engine在标准Python 2.7环境中以两种方式支持第三方库。

  • Built-in libraries : these are automatically enabled in the cloud if declared in your app.yaml file. 内置库 :如果在您的app.yaml文件中声明 ,这些会在云中自动启用。 You may need to install them locally with pip to make them available in the dev server . 您可能需要使用pip 本地安装它们, 以使它们在开发服务器中可用
  • Other third party libraries: these libraries must be pip installed into a folder in your application and uploaded as part of your deployment. 其他第三方库:必须将这些库pip安装到应用程序的文件夹中,并作为部署的一部分上载。 The folder must be declared in your appengine_config.py . 必须在appengine_config.py 声明该文件夹。 These libraries must not be declared in app.yaml , or you get the error you're reporting. 不得app.yaml声明这些库,否则您将得到报告的错误。

requests and urllib3 are not included in the built-in libraries so you will need to: requestsurllib3不包含在内置库中,因此您需要:

  1. Set up vendored libraries folder in appengine_config.py 在appengine_config.py中设置vendored libraries文件夹
  2. pip install -t <your-lib-folder> requests ( urllib3 is installed as part of requests I believe). pip install -t <your-lib-folder> requests (我相信urllib3是作为请求的一部分安装的)。
  3. Ensure <your-lib-folder> is uploaded when you deploy to the cloud. 确保在部署到云时上载<your-lib-folder>

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

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