As previously discussed, we want our client to work in as many cases as possible, including Python 2.7. The http.client package doesn't formally exist in Python 2.7, although interestingly a number of vendor distros support it:
MacOS works:
Python 2.7.16 (default, Jun 5 2020, 22:59:21)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import http.client
>>>
Ubuntu 16 works:
Python 2.7.12 (default, Mar 1 2021, 11:38:31)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import http.client
>>>
But: AWS Linux fails:
Python 2.7.18 (default, Feb 18 2021, 06:07:59)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import http.client
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named http.client
>>>
Solution:
Simple fix: try/catch around the appropriate import.
Background
As previously discussed, we want our client to work in as many cases as possible, including Python 2.7. The
http.client
package doesn't formally exist in Python 2.7, although interestingly a number of vendor distros support it:MacOS works:
Ubuntu 16 works:
But: AWS Linux fails:
Solution:
Simple fix: try/catch around the appropriate import.