27

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

Cœur
39k25 gold badges207 silver badges282 bronze badges
asked Mar 21, 2016 at 23:29
1
  • @MarkB if that's the case, why is it im testing in lambda and getting syntax errors when i use print method without parentheses Commented Aug 31, 2016 at 17:31

6 Answers 6

32

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.

answered May 31, 2016 at 6:51
Sign up to request clarification or add additional context in comments.

1 Comment

The linked to URL is dead.
8

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]"
answered Apr 18, 2017 at 18:17

Comments

4

Python 3.6 is now fully supported by Lambda.

answered Mar 15, 2018 at 21:31

Comments

1

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.

answered Mar 13, 2019 at 7:54

Comments

0

Change runtime language to python version 3. https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

answered May 3, 2020 at 21:22

Comments

0

You could run a lambda function in python 3.7, 3.8 and 3.9

enter image description here

Here you have a sample code to run:

https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html

answered Feb 27, 2023 at 19:51

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.