[英]How to use Stripe Apis on AWS Lambda in Python
我將在 AWS Lambda 上使用 Stripe api 構建一個后端。 但我無法導入條帶庫。
import stripe
這一行給了我這個錯誤。
{
"errorMessage": "Unable to import module 'lambda_function'"
}
任何人都可以幫助我嗎?
Stripe python 庫需要安裝到與您正在編寫的 python 腳本相同的文件夾中。
執行此操作的 pip 命令是:
pip install --install-option="--prefix=/full/local/path/to/your/python/script" --upgrade stripe
這實際上會將庫安裝到您指定路徑中的“lib”文件夾中。 將所有內容從 /full/local/path/to/your/python/script/lib/python2.7/site-packages 復制到 /full/local/path/to/your/python/script
您的目錄將如下所示:
./main.py
./requests/
./requests-2.13.0-py2.7.egg-info/
./stripe/
./stripe-1.55.0-py2.7.egg-info/
壓縮這些文件,然后將該 ZIP 文件上傳到 AWS Lambda。
我知道這個問題已經有一年多了,但它仍然沒有答案,當我搜索同樣的問題時仍然出現了這個問題,所以這是我解決它的方法。
要使用 --target 添加到 James Eberhardt 的答案中,會將文件直接放置到所需位置。
pip install --target="/full/local/path/to/your/python/script" --upgrade stripe
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.