Google云函数Python安装依赖于每个需求

2024-03-29 10:40:35 发布

您现在位置:Python中文网/ 问答频道 /正文

要求.txt

pymystem3==0.2.0

主.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编译之前,是否应该安装依赖项?你知道吗


Tags: totextfrompyimportjsonhelloworld
1条回答
网友
1楼 · 发布于 2024-03-29 10:40:35

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

You can see that the message in your logs is coming from the library itself。你知道吗

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

相关问题 更多 >