Mac - How to fix Python error "ERROR:root:code for hash md5 was not found"

While trying to install a few packages using Pip, I encountered following error: “ERROR:root:code for hash md5 was not found”. For reference, here is the stacktrace that I saw:

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/", line 147, in <module>
    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/", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5

It took me a while to figure out the error is not exactly because of Python, but OpenSSL and Homebrew. Fix is quit simple, you need to switch Homebrew to use right version of open SSL.

$ ls /usr/local/Cellar/openssl  # find out which version of openssl is currently present
$ brew switch openssl 1.0.2q    # and switch to that version
© 2023 Abhinav Saxena   •   Powered by Soopr   •   Theme  Moonwalk