aws cli: ERROR:root:code for hash md5 was not found

Ran into a similar issue with brew install python2 error when trying to use pip.

It's probably because

python@2 was deleted from homebrew/core in commit 028f11f9e:
python@2: delete (https://github.com/Homebrew/homebrew-core/issues/49796)
EOL 1 January 2020.

See this post here https://github.com/Homebrew/homebrew-core/pull/49796 for more details.

To fix this,

  1. run brew uninstall python@2 to uninstall brew installed python@2 this should make default python2 fall back to python2 came with macOS.
  2. uninstall current aws cli by running

    • sudo rm -rf /usr/local/bin/aws
    • sudo rm -rf /usr/local/aws
    • rm AWSCLIV2.pkg
  3. install aws cli again by running

    • sudo curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
    • sudo installer -pkg AWSCLIV2.pkg -target /
  4. if you run aws --version you should see it's linked to python3 instead of python2.

Hope it helps.