I have a "hello-world" python project with serverless framework.
I'm trying to deploy a simple lambda function that needs numpy. But currently, when I run sls deploy
and try to call the lambda function, I get an internal server error
.
Here is the structure of my project:
test_api/
serverless.yml
test_api.py
Pipfile
in test.py
I have:
import numpy as np
def handler(event, context):
return {
"statusCode": 200,
"body": f"numpy version = {np.__version__}"
}
In my serverless.yml
:
service: test_api
frameworkVersion: "3"
provider:
name: aws
runtime: python3.8
region: eu-west-3
stage: dev
functions:
test:
handler: tes_api.handler
events:
- http:
path: test_api
method: get
cors: true
plugins:
- serverless-python-requirements
In Pipfile:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
numpy = "*"
[requires]
python_version = "3.8"
When I deploy, I have no error, but when I call the end point, I get:
If I remove numpy from Pipfile and lambda (I just return "hello" in my lambda), everything works fine.
Why do I get this error and how can I fix it ?