AWS Developer Tools Blog
Announcing the end of support for Python 2.7 in AWS Chalice
On July 15, 2021, AWS will publish a minor version update for AWS Chalice that will require Python 3.6 or greater, formally ending our support for Python 2.7.
The Python Software Foundation (PSF) has stated that “As of January 1st, 2020, no new bug reports, fixes, or changes will be made to Python 2, and Python 2 is no longer supported.” In 2021, numerous Python projects are ending their support for Python 2, including the AWS SDK for Python which Chalice depends on, and we will be joining these projects in dropping Python 2 support to ensure that AWS Chalice continues to be secure and up-to-date.
AWS Lambda recently announced they are ending support for Python 2.7 on July 15, 2021. From that deprecation date, Lambda will no longer apply security patches and other updates to the Python 2.7 runtime used by Lambda functions, and you will no longer be able to create new functions using the Python 2.7 runtime. Chalice maintains parity with all Python versions supported by Lambda, including any runtime deprecations.
How do I use Python 3 with my Chalice application?
Chalice will create Lambda functions based on the version of Python you are using in your development environment. To use Python 3 with Chalice, ensure the interpreter for your project or virtual environment is using Python 3.6 or greater. See our documentation for more details.
My Chalice application uses Python 2.7, what should I do?
You’ll first need to determine if your code is compatible with Python 3. The easiest way to do this is to try to run your application tests in Python 3. Chalice supports both Python 2 and Python 3, and its interfaces remain the same between both versions.
If your code is not compatible with Python 3.6 or greater, there are a number of guides and tools to help you migrate. The Python Software Foundation (PSF), provides a tool (2to3) that should automatically migrate most code bases from Python 2 to Python 3. For steps and best practices, the PSF also provides a more in-depth migration guide.
Once your application code is compatible with Python 3.6 or greater, make sure to switch your project interpreter or virtual environment to Python 3. Chalice will detect this change and switch your Lambda function runtime to the corresponding version of Python 3.
What if I need additional help?
If you have any additional questions or comments, please reach out on our GitHub repository.