Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 运行时警告:父模块';src&x27;处理绝对导入时未找到-AWS Lambda_Python_Amazon Web Services_Aws Lambda - Fatal编程技术网

Python 运行时警告:父模块';src&x27;处理绝对导入时未找到-AWS Lambda

Python 运行时警告:父模块';src&x27;处理绝对导入时未找到-AWS Lambda,python,amazon-web-services,aws-lambda,Python,Amazon Web Services,Aws Lambda,我在使用简单的Python Lambda函数时遇到问题。Lambda(由Zapier调用)函数基本上创建一个汇合页面并调用另一个Zapier Webhook。我在S3中上传一个.zip文件,其中包含所需包的所有文件夹,然后是一个src文件夹,其中包含我的Python文件,该文件具有我的处理函数 .zip-->src/lambda_function.py,然后调用处理函数 在lambda_function.py的顶部,我有以下内容: import string import json import

我在使用简单的Python Lambda函数时遇到问题。Lambda(由Zapier调用)函数基本上创建一个汇合页面并调用另一个Zapier Webhook。我在S3中上传一个.zip文件,其中包含所需包的所有文件夹,然后是一个src文件夹,其中包含我的Python文件,该文件具有我的处理函数

.zip-->src/lambda_function.py,然后调用处理函数

在lambda_function.py的顶部,我有以下内容:

import string
import json
import pyconfluence as pyco
import requests
import os
import time

def create_page(name, content, label):
    data = {}
    data["type"] = "page"
    data["title"] = name
    data["ancestors"] = [{"id": str(12345678)}] #172949526 is the Parent
    data["space"] = {"key": "PK"}
    data["body"] = {"storage": {"value": content, "representation": "storage"}}
    data["metadata"] = {"labels": [{"name": label}]}
    return pyco.api.rest("/", "POST", json.dumps(data))

def lambda_handler(event, context):
    # Page 12345678 that is in fact a representation of the template
    content = pyco.get_page_content(12345678)
    page_title = event['issue_key'] + ": " + event['issue_title']
    content = string.replace(content, "PK-200", event['issue_key'])  
    create_page(page_title, content, "active-product-requirement")
    api_url = "https://acmein.atlassian.net/rest/api/2/issue/"+event['issue_key']+"/remotelink/"

    webhook = 'https://hooks.zapier.com/hooks/catch/123456/8v6fde/'

    requisite_headers = {'Accept': 'application/json',
                         'Content-Type': 'application/json'}
    auth = (os.environ["PYCONFLUENCE_USER"], os.environ["PYCONFLUENCE_TOKEN"])
    result = requests.get(api_url, headers=requisite_headers, auth=auth).json()

    if len(result) > 0:
        confluence_url = result[0]["object"]["url"]
    else:
        confluence_url = "Error getting the page"
    callback = requests.post(webhook, data={'issue_key': event['issue_key'], 'confluence_url': confluence_url })
    return ["Success"]
在我的CloudWatch日志中,我有以下错误:


您必须压缩
src
文件夹的内容,而不是
src
文件夹本身。python模块(
lambda_function.py
)应该位于zip的第一级。 见:

压缩目录内容,而不是目录。Zip文件的内容作为Lambda函数的当前工作目录提供


如果您需要代码中的问题的帮助,您需要向我们展示代码。你让我们猜猜你写了什么,然后告诉你应该写什么。