AWS Developer Tools Blog

Announcing the end of support for Python 2.7 in the AWS SDK for Python and AWS CLI v1

On July 15, 2021, in order to continue supporting our customers with tools that are secure and maintainable, AWS will publish a minor version bump of the AWS Command Line Interface (AWS CLI) v1 and AWS SDK for Python (boto3 and botocore). These new versions will require a Python 3.6+ runtime, formally ending our Python 2.7 support.

Per the Python Software Foundation (PSF), Python 2.7.18 was the final release of Python 2. With its release, the PSF states 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.” Until this year, many industry Python projects and packages have continued to support Python 2.7. As we enter 2021, these projects are stopping their support for Python 2, and we will be joining these deprecations to maintain secure and up-to-date SDKs.

I use AWS CLI v2, what should I do?

If you already use AWS CLI v2, no action is required. You are not impacted by this announcement.

I use AWS CLI v1, how do I upgrade to the Python 3.6+ runtime?

For AWS CLI v1 users, we recommend upgrading to our recently released AWS CLI v2. AWS CLI v2 doesn’t have a dependency on a local Python runtime, which allows you to avoid these deprecations in the future. For installation instructions, see Installing, updating, and uninstalling the AWS CLI version 2.

Alternatively, you can take on the following actions based on how you have currently installed the AWS CLI.

  • MSI Installer – If you install the AWS CLI v1 using the Windows MSI Installer for Python 3 [32 bit] [64 bit], you’re not impacted by this deprecation. These MSI Installers remain up to date with each release. If you’re using the Windows MSI Installer for Python 2 [32 bit] [64 bit], these links will automatically be changed to point to the latest Python 3 installer on the deprecation date.
  • Pip Installation – If you’re currently using Python 2.7 as your runtime for AWS CLI v1, we recommend downloading Python 3.6 or later. You can follow our CLI upgrade guide for getting your environment setup.
  • Bundled Installer – If you install the AWS CLI v1 using the bundled installer, we recommend downloading Python 3.6 or later. Once you’ve installed your new version of Python, you can follow the appropriate Linux or macOS guide for installation with a specific Python runtime.

I use the AWS SDK for Python (boto3/botocore), what should I do?

If you’re using boto3, you will need to first determine if your code is currently Python 3 compatible. The easiest way to do this is to try running it in an environment with Python 3. The SDK interfaces remain consistent between the two Python versions, but your code may not.

In the event that your code doesn’t work with Python 3, 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. If you have a code base that needs to remain compatible with both versions, we’d recommend looking at python-modernize or futurize. For steps and best practices, the PSF also provides a more in-depth migration guide.

If your code is working in Python 3, you should only need to install Python 3.6+ in your production environments. For services hosted on Amazon Elastic Compute Cloud (Amazon EC2), most AWS Quick Start AMIs now provide Python 3.6+ out of the box:

  • Amazon Linux 2 (minimal setup required)
  • Red Hat Enterprise Linux 8
  • SUSE Linux Enterprise Server 15 SP1
  • Ubuntu 18.04
  • Ubuntu 20.04 LTS

What if I can’t upgrade to Python 3?

In the event that you’re unable to migrate to Python 3, you don’t need to worry. Existing versions of the AWS CLI v1 and boto3/botocore will continue to operate after the deprecation date. Depending on your installation method, you will either stop receiving updates after the deprecation date, or will need to download a Python 2 compatible release. For more information, see our AWS CLI v1 migration and Boto3 migration guides.

Conclusion

If you’re currently using Python 2.7 as your runtime for AWS SDK for Python or AWS CLI v1, we encourage you to upgrade to Python 3.6 or later. Please share your questions, comments, and issues with us on GitHub.

Nate Prewitt

Nate Prewitt

Nate is a Software Development Engineer working on the AWS SDK for Python and AWS CLI. He is passionate about building tools to improve the developer experience. You can find him on Twitter @nateprewitt and GitHub @nateprewitt.