Lambda 上缺少处理程序错误,但处理程序存在于脚本中

Missing handler error on Lambda but handler exists in script

我的 lambda_function.py 文件如下所示:

from urllib.request import urlopen
from google.cloud import bigquery
import json

url = "https://data2.unhcr.org/population/get/timeseries?widget_id=286725&sv_id=54&population_group=5460&frequency=day&fromDate=1900-01-01"
bq_client = bigquery.Client()

def lambda_helper(event, context):
    response = urlopen(url)
    data_json = json.loads(response.read())
    bq_client.load_table_from_json(data_json['data']['timeseries'], "xxx.xxxx.tablename")

但每次我将其压缩并上传到我的 Lambda 时,我都会收到此错误:

{
  "errorMessage": "Handler 'lambda_handler' missing on module 'lambda_function'",
  "errorType": "Runtime.HandlerNotFound",
  "stackTrace": []
}

即使我清楚地在这个模块中编写了那个函数,是否有一个原因会抛出这个错误?这让我抓狂。感谢您的帮助!

应该是:

def lambda_handler(event, context):

没有

def lambda_helper(event, context):