| 1 |
.. _guide_migration_py3: |
| 2 |
|
| 3 |
Migrating to Python 3 |
| 4 |
===================== |
| 5 |
|
| 6 |
Python 2.7 was deprecated by the `Python Software Foundation <https://www.python.org/psf-landing/>`_ |
| 7 |
on January 1, 2020 following a multi-year process of phasing it out. Because of this, AWS has |
| 8 |
deprecated support for Python 2.7, which means that releases of Boto3 issued after the deprecation |
| 9 |
date will no longer work on Python 2.7. |
| 10 |
|
| 11 |
This affects both modules that comprise the AWS SDK for Python: Botocore (the underlying low-level |
| 12 |
module) and Boto3 (which implements the API functionality and higher-level features). |
| 13 |
|
| 14 |
Timeline |
| 15 |
-------- |
| 16 |
Going forward, all projects using Boto3 need to transition to a supported version of Python 3. Boto3 and |
| 17 |
Botocore ended support for Python 2.7 on July 15, 2021. |
| 18 |
|
| 19 |
Updating your project to use Python 3 |
| 20 |
------------------------------------- |
| 21 |
|
| 22 |
Before you begin to update your project and environment, make sure you’ve installed or updated to a |
| 23 |
supported version of Python as described in :ref:`upgrade to Python 3 <quickstart_install_python>`. You can |
| 24 |
get Python from the `PSF web site <https://www.python.org/downloads>`_ or using your local package |
| 25 |
manager. |
| 26 |
|
| 27 |
After you have installed Python 3, you can upgrade the SDK. To do so, you need to update the Boto3 |
| 28 |
Python package. You can do this globally or within your virtual environment if you use one for your |
| 29 |
project. |
| 30 |
|
| 31 |
To update the AWS SDK for Python |
| 32 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 33 |
|
| 34 |
1. Uninstall the currently installed copies of Boto3 and Botocore:: |
| 35 |
|
| 36 |
$ python -m pip uninstall boto3 botocore |
| 37 |
|
| 38 |
2. Install the new version of Boto3. This will also install Botocore, which it requires:: |
| 39 |
|
| 40 |
$ python3 -m pip install boto3 |
| 41 |
|
| 42 |
3. (Optional) Verify that the SDK is using the correct version of Python:: |
| 43 |
|
| 44 |
$ python3 -c "import boto3, sys; print(f'{sys.version} \nboto3: {boto3.__version__}')" |
| 45 |
3.x.y (default, Jan 7 2021, 17:11:21) |
| 46 |
[GCC 7.3.1 20180712 (Red Hat 7.3.1-11)] |
| 47 |
boto3: 1.16.15 |
| 48 |
|
| 49 |
If you're unable to upgrade to Python 3 |
| 50 |
--------------------------------------- |
| 51 |
|
| 52 |
It may be that you're unable to upgrade to Python 3, for example if you have a large project that's |
| 53 |
heavily dependent on syntax or features that no longer work as desired in Python 3. It's also |
| 54 |
possible that you need to postpone the Python transition while you finish updates to your code. |
| 55 |
|
| 56 |
Under these circumstances, you should plan on pinning your project's install of Boto3 to the last |
| 57 |
release that supports the Python version you use, then not updating Boto3 further. You can then keep |
| 58 |
using an existing installation of Boto3 on Python 2, even after its deprecation date, with the |
| 59 |
understanding that deprecated versions of Boto3 will not receive further feature or security |
| 60 |
updates. |
| 61 |
|
| 62 |
pip-based installations |
| 63 |
~~~~~~~~~~~~~~~~~~~~~~~ |
| 64 |
|
| 65 |
If you installed Boto3 using :command:`pip` 10.0 or later, you'll automatically stop receiving Boto3 |
| 66 |
updates after the last Python 2 compatible version of the SDK is installed. If you're using an older |
| 67 |
version of :command:`pip`, you need to pin your Boto3 install to no later than version 1.17. |
| 68 |
|
| 69 |
Other installation methods |
| 70 |
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 71 |
|
| 72 |
If you installed Boto3 and Botocore from source or by any other method, be sure to download and |
| 73 |
install a version released prior to the Python 2.7 deprecation date. |