"ERROR:root:code for hash md5 was not found" when using any hg mercurial commands

Running brew reinstall python@2 didn't work for my existing Python 2.7 virtual environments. Inside them there were still ERROR:root:code for hash sha1 was not found errors.

I encountered this problem after I ran brew upgrade openssl. And here's the fix:

$ ls /usr/local/Cellar/openssl

...which shows

1.0.2t

According to the existing version, run:

$ brew switch openssl 1.0.2t

...which shows

Cleaning /usr/local/Cellar/openssl/1.0.2t
Opt link created for /usr/local/Cellar/openssl/1.0.2t

After that, run the following command in a Python 2.7 virtualenv:

(my-venv) $ python -c "import hashlib;m=hashlib.md5();print(m.hexdigest())"

...which shows

d41d8cd98f00b204e9800998ecf8427e

No more errors.


Managed to fix this by first unlinking openssl

brew unlink openssl

And then reinstalling python

brew reinstall python@2

I also noticed that when running 'brew doctor' there was a warning related to an openssl folder found in /usr/local/include/node/. I deleted this folder before running the above commands (not sure if related)


The case for me is that when I install dependencies of a django web app, it messes up the environment. When I type cd, it shows the same error.

The problem was the openssl library, it can not find the correct ones.

If you are on Macintosh, you can type

ls /usr/local/Cellar/openssl

to see all the versions,

brew switch openssl 1.0.XXXX

to choose the available openssl version.

Then the error is gone :)