Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am writing a Python Lambda in Cloud9. Trying to run it (locally, before deploying to the backend), I'm receiving this error:

Invalid lambda response received: Invalid API Gateway Response Keys: {'errorType', 'errorMessage'} in {'errorMessage': "Unable to import module 'getPersonByKey': No module named 'requests'", 'errorType': 'Runtime.ImportModuleError'}

I am NOT using requests in my code, not importing it, it is not included in the requirements.txt file.

This is my Lambda code:

import json
import pyTigerGraphBeta as tg

def lambda_handler(event, context):
    try:
        conn = tg.TigerGraphConnection(host="https://skillblaster-dev.i.tgcloud.io", graphname="SkillBlasterDev", useCert=True)
        conn.apiToken = conn.getToken("rak++++++++++41f")[0]

        print("Calling to run installed query")
        result = conn.runInstalledQuery("getPersonByKey", {"keyPerson":"[email protected]"})

    except Exception as e:
        print(e)    
        raise e

    return {
        "statusCode": 200,
        "body": json.dumps("TEST"),
    }

What am I missing?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

Most likely the pyTigerGraphBeta lib uses requests library under the hood. I faced this issue couple of times.

The Solution would be adding requests library to your requirements.txt (or whatever package manager you use - poetry, pip, pipenv) so it will end up in the zip file where your lambda code is (that you upload to s3).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...