部署不会生成所有包

Deploy does not generate all packages

我正在使用一个名为 DialogFlow 的 Google 库。在过去的 6 或 7 天里,所有导入该库的 lambda 函数都开始出现初始化错误。

我注意到它几乎与无服务器框架从版本 1.31.0 升级到 1.32.0 的时间相同。在我的 serverless.yml 文件中,我输入了:frameworkVersion: ">=1.0.0 <2.0.0"

如果我编译这样一个简单的代码:

import dialogflow


def hi(event, context):
    return {
        "statusCode": 200,
        "body": "ahhh hiiii"
    }

lambda中产生的错误如下:

START RequestId: 907fe23d-c2b1-11e8-b745-27859211eefc Version: $LATEST module initialization error: The 'google-api-core' distribution was not found and is required by the application

END RequestId: 907fe23d-c2b1-11e8-b745-27859211eefc REPORT RequestId: 907fe23d-c2b1-11e8-b745-27859211eefc Duration: 47.02 ms Billed Duration: 100 ms Memory Size: 1024 MB Max Memory Used: 32 MB module initialization error The 'google-api-core' distribution was not found and is required by the application

问题在于使用低级语言(通常是 C 语言)的库。而serverless在生成数据包的时候,那些语言是不会发送的

解决方案:启用docker打包,通过serverless-python-requirements插件。

custom:
  pythonRequirements:
    dockerizePip: true