simple-serverless-fastapi-example icon indicating copy to clipboard operation
simple-serverless-fastapi-example copied to clipboard

when i am deploying it to lambda i am getting an errr i.e fastapi module not found

Open singhbhupinder651 opened this issue 4 years ago • 3 comments

singhbhupinder651 avatar May 04 '21 09:05 singhbhupinder651

which are files need to be there in functions.zip?

singhbhupinder651 avatar May 04 '21 09:05 singhbhupinder651

@singhbhupinder651 It sounds like you prob don't have all the Python dependencies in the root of your .zip file.

When you're running it on your local machine Python will usually look for them in

my_project_root/.env/lib/site-packages/fastapi

however Lambda will look for them in the root of your .zip file like

my_project_root/fastapi

Here is an example.

seantbaier avatar May 05 '21 09:05 seantbaier

try this:

cd venv/lib/python3.9/site-packages || exit
zip -r9 ../../../../function.zip .
cd ../../../../
zip -r9 function.zip app

hdsuperman avatar Mar 24 '23 09:03 hdsuperman