【问题标题】:Google Cloud Function Python installing dependency on each requestGoogle Cloud Function Python 在每个请求上安装依赖项
【发布时间】:2018-09-26 09:48:03
【问题描述】:

requirements.txt:

pymystem3==0.2.0

ma​​in.py:

from pymystem3 import Mystem
import json

def hello_world(request):
    request_json = request.get_json()
    if request_json and 'text' in request_json:
        text = request_json['text']
        m = Mystem()
        lemmas = m.lemmatize(text)

        return json.dumps(m.analyze(text), ensure_ascii=False, encoding='utf8', sort_keys=True, indent=2)
    else:
        return 'No text provided'

登录谷歌云:

hello_world
032ljsdfawo
Function execution started

hello_world
032ljsdfawo
Installing mystem to /tmp/.local/bin/mystem from http://download.cdn.yandex.net/mystem/mystem-3.1-linux-64bit.tar.gz

Expand all | Collapse all {
 insertId:  "000000-a9eaa07b-d936-45d8-a186-927cc94246d6"  
 labels: {…}  
 logName:  "projects/project_name/logs/cloudfunctions.googleapis.com%2Fcloud-functions"  
 receiveTimestamp:  "2018-09-26T09:41:31.070927654Z"  
 resource: {…}  
 severity:  "ERROR"  
 textPayload:  "Installing mystem to /tmp/.local/bin/mystem from http://download.cdn.yandex.net/mystem/mystem-3.1-linux-64bit.tar.gz"  
 timestamp:  "2018-09-26T09:41:19.595Z"  
}

我是 python 新手,所以这可能是一个非常简单的错误。也许依赖项假设在以某种方式部署函数并使用main.py 编译之前安装?

【问题讨论】:

    标签: python google-cloud-platform google-cloud-functions


    【解决方案1】:

    这是由于 pymsystem 库的不幸行为造成的:它没有在 Python 包中包含所需的所有内容,而是尝试在运行时下载其他内容,特别是每次导入时。

    You can see that the message in your logs is coming from the library itself.

    该库似乎正在尝试确定它是否已安装,但这可能无法正常工作。我建议提交问题on the project's issue tracker。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-17
      • 1970-01-01
      • 2019-10-23
      • 2013-08-30
      • 2021-01-25
      • 1970-01-01
      相关资源
      最近更新 更多