using Python 3 with AWS lambda

孤人 提交于 2019-12-31 20:02:13

问题


Can one use application built with Python3 in lambda, and not just python2.7. Possibly looking at options around - https://gun.io/blog/announcing-zappa-serverless-python-aws-lambda/

AWS lambda documentation mentions about python2.7.

Is there some example code which I could try for python3.0 with lambda


回答1:


Lambda functions run in a container on a well-known AMI. While you must handle the initial event with Python2.7, you can call out to anything installed on the AMI. In particular, Python3 is already installed. It's a bit complicated, but you can establish a virtualenv to take advantage of the installed python3.

For a few of the details, see http://www.cloudtrek.com.au/blog/running-python-3-on-aws-lambda/.

Edit: that link went dead. Try https://www.linkedin.com/pulse/running-python-3-aws-lambda-lyndon-swan.




回答2:


Python 3.6 is now available in Ohio! (us-east-2)

I ran:

def lambda_handler(event, context):
    # TODO implement
    return sys.version

And it kicked back:

"3.6.1 (default, Mar 27 2017, 23:56:45) \n[GCC 4.9.3]"



回答3:


Python 3.6 is now fully supported by Lambda.




回答4:


You can use Python 3 with aws lambda. when you are creating an Aws lambda function there is an option where you can use a python 3 as a version and execute your code.



来源:https://stackoverflow.com/questions/36143563/using-python-3-with-aws-lambda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!