I am going to build a backend using Stripe api on AWS Lambda. But I can't import stripe library.
import stripe
This line gives me this error.
{
"errorMessage": "Unable to import module 'lambda_function'"
}
Anybody can help me?
The Stripe python libraries need to be installed to the same folder as the python script you are writing.
The pip command to do this is:
pip install --install-option="--prefix=/full/local/path/to/your/python/script" --upgrade stripe
This will actually install the libraries into the "lib" folder in the path you indicated. Copy everything from /full/local/path/to/your/python/script/lib/python2.7/site-packages to /full/local/path/to/your/python/script
Your directory will then look something like this:
./main.py
./requests/
./requests-2.13.0-py2.7.egg-info/
./stripe/
./stripe-1.55.0-py2.7.egg-info/
Zip up those files and then upload that ZIP file to AWS Lambda.
I know this question is over a year old, but it's still unanswered, and is what still turned up when I searched for this same problem, so here is how I solved it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With