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

Mercurial ERROR:root:code for hash md5 was not found – when using any hg mercurial commands is an error which occurs for many reasons when you run hg mercurial commands.

Today, I will explain why this error takes place and how to fix it, while also presenting the steps in detail and adding other solutions that could solve the error.

Exploring the Mercurial ERROR:root:code for hash md5 was not found – when using any hg mercurial commands

This is an error which occurs for many reasons when you run hg mercurial commands.

Beware of mixing between errors. Double check if the error message looks like the error message bellow, then continue.

                                                                       #
AttributeError: 'module' object has no attribute 'md5'
                                                                       #

The methods bellow should be enough to solve your problem, I wish you good luck.

Solution 1 : reinstall python after unlinking openssl

A simple and effective solution is to unlink openssl.

You can use the command bellow in order to unlink openssl

                                                                       #
brew unlink openssl
                                                                       #

After that you can just reinstall python using this command

                                                                       #
brew reinstall python@2
                                                                       #

I hope this method has solved your problem, try the method bellow if that is not the case

Solution 2 : brew switch the package version

This is a very well known problem, which can be solved with a relatively easy step by step solution.

In this example I am going to assume that the error happened when I was trying to install a python package.

                                                                       #
brew install <package>
                                                                       #

First, run this command

                                                                       #
$ ls /usr/local/Cellar/<package>
                                                                       #

<package> should be replaced with the package you are trying to install, the command is going give you the version you were trying to install, for the sake of this example let us call it <version>

Next, run this command

                                                                       #
$ brew switch <package> <version>
                                                                       #

I hope you already have a python virtualenv , If you do not have one please create one.

Then, run this command in the virtualenv. The error should be gone on your next run of the first command ( the one that failed )

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

I hope this method has solved this problem, try the last method in this post bellow if that is not the case

Solution 3 : remove python after unlinking openssl

This method is exactly like the first method of reinstalling python we will be removing python

This works great with macOS Catalina since it already has python installed

We will work with that instead of installing our own version of python

So, after unlinking openssl like in the first method, run the command bellow

                                                                       #
brew remove python@2
                                                                       #

If the methods above helped you, consider supporting us on Kofi, any help is appreciated.

Summing-up : 

We arrived at the end of this quest to solve this annoying error, I hope me sharing my experience with you helped, I hope the other solutions helped, If you like this website support us on Kofi and keep browsing, thank you.

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/