如何在AWS Lambda上安装pymysql [英] How to install pymysql on AWS lambda
问题描述
我在此处和
I've looked here and here as I've been trying to work out how to get pymysql
running on AWS lambda. The examples I've looked at so far are extremely complex, and with the GitHub tutorial I got as far as IAM before I started running into permissions errors I didn't know how to solve.
从字面上看,我要做的就是在预先构建的AWS lambda控制台模板中调用import pymysql
.
Literally, all I want to be able to do is call import pymysql
within the prebuilt AWS lambda console template.
这似乎是一个简单的问题,但是我很难找到一个清晰,分步的工作,以了解如何使新的依赖项适用于我的lambda函数.理想情况下,该示例将通过AWS CLI not ,因为显然有一个控制台选项,这似乎可以减轻程序的麻烦.
It seems like a simple problem, but I'm having a hard time finding a clear, step-by-step work through of how to get new dependencies to work for my lambda function. Ideally the example would not by via AWS CLI, since apparently there is a console option and this seems like it would take some of the headache out of the process.
干杯
亚伦
推荐答案
我遇到了 Redis python库的类似问题. 我会按照您在第二个链接中提到的文档说明进行操作.
I was facing similar problem with Redis python library. I follow the same documentation instructions which you mentioned in your second link.
下面是示例片段供您参考:
here is example snippet for your reference :
创建新目录 MyPythonLambda ,并将 MyPythonLambda.py 放在同一目录中.
Create new directory MyPythonLambda and put MyPythonLambda.py in the same.
假设 MyPythonLambda/MyPythonLambda.py 是包含处理程序的主要lambda.
Assume MyPythonLambda/MyPythonLambda.py is main lambda containing handler.
cd MyPythonLambda/
pip install redis -t .
zip -r MyPythonLambda.zip *
从S3或本地文件系统中的lambda创建中上载/导入zip.
Upload/import zip in lambda creation from S3 or your local file system.
我认为您需要以类似的方式创建包含python mysql库的zip文件.
I think you need to create zip file in similar way containing your python mysql library.
这篇关于如何在AWS Lambda上安装pymysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!