aws cli: ERROR:root:code for hash md5 was not found : <p>When trying to run the AWS CLI, I am getting this error:</p>

<pre><code>aws
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in &lt;module&gt;
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in &lt;module&gt;
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in &lt;module&gt;
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in &lt;module&gt;
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in &lt;module&gt;
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in &lt;module&gt;
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
Traceback (most recent call last):
  File "/usr/local/bin/aws", line 19, in &lt;module&gt;
    import awscli.clidriver
  File "/usr/local/lib/python2.7/site-packages/awscli/clidriver.py", line 17, in &lt;module&gt;
    import botocore.session
  File "/usr/local/lib/python2.7/site-packages/botocore/session.py", line 29, in &lt;module&gt;
    import botocore.configloader
  File "/usr/local/lib/python2.7/site-packages/botocore/configloader.py", line 19, in &lt;module&gt;
    from botocore.compat import six
  File "/usr/local/lib/python2.7/site-packages/botocore/compat.py", line 25, in &lt;module&gt;
    from botocore.exceptions import MD5UnavailableError
  File "/usr/local/lib/python2.7/site-packages/botocore/exceptions.py", line 15, in &lt;module&gt;
    from botocore.vendored import requests
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/__init__.py", line 58, in &lt;module&gt;
    from . import utils
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/utils.py", line 26, in &lt;module&gt;
    from .compat import parse_http_list as _parse_list_header
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/compat.py", line 7, in &lt;module&gt;
    from .packages import chardet
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/__init__.py", line 3, in &lt;module&gt;
    from . import urllib3
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/__init__.py", line 10, in &lt;module&gt;
    from .connectionpool import (
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 31, in &lt;module&gt;
    from .connection import (
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/connection.py", line 45, in &lt;module&gt;
    from .util.ssl_ import (
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/util/__init__.py", line 5, in &lt;module&gt;
    from .ssl_ import (
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/util/ssl_.py", line 2, in &lt;module&gt;
    from hashlib import md5, sha1, sha256
ImportError: cannot import name md5
</code></pre>

<p>I tried the solution from <a href="https://stackoverflow.com/questions/59269208/errorrootcode-for-hash-md5-was-not-found-not-able-to-use-any-hg-mercurial-co">this issue</a> but they do not work:</p>

<pre><code>brew reinstall python@2
==&gt; Reinstalling python@2
Error: An exception occurred within a child process:
  FormulaUnavailableError: No available formula with the name "/usr/local/opt/python@2/.brew/python@2.rb"
</code></pre>

<p>I thought it might not be installed, but it already is:</p>

<pre><code>brew install python@2
Warning: python@2 2.7.15_1 is already installed and up-to-date
To reinstall 2.7.15_1, run `brew reinstall python@2`
</code></pre>

<p>Running <code>brew doctor</code> shows that <code>python</code> is unliked, but running <code>brew link python</code> fails because of a symlink belonging to <code>python@2</code>.</p>

<pre><code>brew link python
Linking /usr/local/Cellar/python/3.7.6_1...
Error: Could not symlink Frameworks/Python.framework/Headers
Target /usr/local/Frameworks/Python.framework/Headers
is a symlink belonging to python@2. You can unlink it:
  brew unlink python@2

To force the link and overwrite all conflicting files:
  brew link --overwrite python

To list all files that would be deleted:
  brew link --overwrite --dry-run python
</code></pre>

<p>The commands recommended seem to go in circle and none of them manage to solve the issue. I am a bit stuck - how do I recover from these errors?</p>
