'Use library for `SAM` lambda project

I am developing lambda project by SAM

My simple python script using pandas

import json
import requests
import pandas as pd

def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "body": json.dumps({
            "message": "hello world",
            # "location": ip.text.replace("\n", "")
        }),
    }

in local.

$pipenv shell
$pip install pandas
$sam build
$sam deploy
$sam local invoke "HelloWorldFunction" -e events/event.json

If I don't use pandas my local lambda works on SAM well.

When I want to use the library, the error comes like below.

How can I use library for SAM lambda project??

Maybe I am still unclear about SAM basic idea. Any help appreciated.

{"errorMessage": "Unable to import module 'app': No module named 'pandas'", "errorType": "Runtime.ImportModuleError", "requestId": "df7c4546-d12c-403f-9271-ab994c97b24b", "stackTrace": []}END RequestId: df7c4546-d12c-403f-9271-ab994c97b24b
REPORT RequestId: df7c4546-d12c-403f-9271-ab994c97b24b  Init Duration: 0.38 ms  Duration: 712.51 ms Billed Duration: 713 ms Memory Size: 128 MB Max Memory Used: 128 MB 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source