Bootstrap FreeKB - Python (Scripting) - Resolve DeprecationWarning
Python (Scripting) - Resolve DeprecationWarning

Updated:   |  Python (Scripting) articles

Let's say your Python script is returning a Deprecation Warning, perhaps something like this.

/usr/local/lib/python3.6/site-packages/boto3/compat.py:88: PythonDeprecationWarning: 
Boto3 will no longer support Python 3.6 starting May 30, 2022. 
To continue receiving service updates, bug fixes, and security updates please upgrade to Python 3.7 or later. 
More information can be found here: https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/
  warnings.warn(warning, PythonDeprecationWarning)

 

In this example, the Deprecation Warning is with boto3, meaning that the Python script is probably importing boto3.

#!/usr/bin/python3
import boto3

 

Notice in this example that the warning mentions upgrading to Python version 3.7 or higher. This should mean that the Python version being used is below 3.7.

~]$ python3 --version
Python 3.6.8

 

Upgrading Python is no trivial matter. In fact, I usually end up going with a Python virtual environment with the version of Python I want to run. Check out my article Install Python in a virtual environment on Linux.

Or, you can suppress, the Deprecation Warning, something like this.

#!/usr/bin/python3
import boto3
boto3.compat.filter_python_deprecation_warnings()

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 0731ec in the box below so that we can be sure you are a human.