"ERROR:root:code for hash md5 was not found" when using any hg mercurial commands
Solution 1
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.
Solution 2
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)
Solution 3
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 :)
Solution 4
Just uninstall python2
$ brew uninstall python@2
If there is any error :
$ brew uninstall --ignore-dependencies python@2
Solution 5
My problem was having pyenv
installed and pointing to an old python 2 version
Uninstall python@2 (python2 was EOL since Jan 1st, 2020)
$ brew uninstall python@2
Uninstalling /usr/local/Cellar/python@2/2.7.15_1... (4,169 files, 76.0MB)
then
$ pyenv versions
system
* 2.7.12 (set by /Users/admin/.python-version)
3.4.5
3.7.7
$ pyenv local system
$ pyenv global system
Related videos on Youtube
poca
Updated on September 23, 2021Comments
-
poca over 2 years
When trying to use any
hg
Mercurial commands on the console, I keep getting this error. I installed Python using Homebrew and I am running Mac OS Catalina v. 10.15.1.Any reference would be appreciated. Here is the error I'm getting:
hg commit --amend ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python@2/2.7.15_3/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_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python@2/2.7.15_3/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_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python@2/2.7.15_3/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_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python@2/2.7.15_3/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_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python@2/2.7.15_3/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_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python@2/2.7.15_3/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/hg", line 43, in <module> dispatch.run() File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 150, in __getattr__ self._load() File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 94, in _load _origimport, head, globals, locals, None, level) File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 43, in _hgextimport return importfunc(name, globals, *args, **kwargs) File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/dispatch.py", line 625, in <module> class lazyaliasentry(object): File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/dispatch.py", line 636, in lazyaliasentry @util.propertycache File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 150, in __getattr__ self._load() File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 94, in _load _origimport, head, globals, locals, None, level) File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 43, in _hgextimport return importfunc(name, globals, *args, **kwargs) File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/util.py", line 180, in <module> 'md5': hashlib.md5, File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 151, in __getattr__ return getattr(self._module, attr) AttributeError: 'module' object has no attribute 'md5'
I also tried following the instruction on this issue but none of the solutions seem to work
brew link openssl --force Warning: Refusing to link macOS-provided software: [email protected] If you need to have [email protected] first in your PATH run: echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc For compilers to find [email protected] you may need to set: export LDFLAGS="-L/usr/local/opt/[email protected]/lib" export CPPFLAGS="-I/usr/local/opt/[email protected]/include" For pkg-config to find [email protected] you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
-
StayOnTarget over 4 yearsYour link to issue 1 is missing.
-
StayOnTarget over 4 yearsThis sounds like a Python issue: stackoverflow.com/questions/20399331/… or stackoverflow.com/questions/41798118/…
-
poca over 4 yearsAny solutions for MacOS? I did try these solutions but none of them are working. I keep getting the same error. When I try to link openssl as i pasted in my question I get the error pasted there. I also tried running these 4 commands but nothing happened: echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc export LDFLAGS="-L/usr/local/opt/[email protected]/lib" export CPPFLAGS="-I/usr/local/opt/[email protected]/include" export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
-
taper almost 4 yearsStrangely enough I had the same issue with YCM in Macvim and this answer solved my problem.
-
-
chrysillo over 4 yearsI didn't have openssl linked but reinstalling python did it for me. Thanks!
-
NathanQ about 4 yearsThis helped me on a mac catalina update or maybe the bash -> zsh where tons of things like this were broken.
-
Matt Coady about 4 yearsI didn't have 1.0.2q but doing the same with 1.0.2r also worked
-
carpii about 4 yearsThanks, I would never have figured that out. I had this problem after trying to install pipx via homebrew
-
chaosguru about 4 yearsI had to relink the azure-cli with brew
-
hb5fa about 4 yearsYes. This works for me. I have spent days on this and in fear of having to re-image my machine. I'd tried to reinstall python@2 numerous time but still could not fix the problem. This one definitely works. MacOS Mojave 10.14.6.
-
Ilya Saunkin about 4 yearsFlawless steps.
-
Petter Måhlén about 4 yearsThis helped me too, but my homebrew claimed I had 1.1.1f installed for openssl when trying "brew upgrade openssl". However, switching to the latest 1.0.x version I had allowed me to proceed.
-
Florent Roques about 4 yearsrunning brew switch openssl [version] did it for me, didn't need last command
-
Florent Roques about 4 yearsone liner
bash ls /usr/local/Cellar/openssl | xargs brew switch openssl
-
Jaybeecave about 4 years@FlorentRoques that's because you would have had the same version as the example. In my case
ls /usr/local/Cellar/openssl
returned1.0.2s
so I needed to runbrew switch openssl 1.0.2s
-
gtheys about 4 yearsworks had 2 openssl installations in brew which I needed to compile something ellse
-
Sagar Ranglani about 4 yearsWow Wow Wow! :-)
-
Paul about 4 yearsAs of Feb. 10, 2020, python@2 is removed from homebrew and this answer will not work. See the above answer by @Rockallite, which worked perfectly for me.
-
poca about 4 yearsThanks for the update @Paul , I marked the above answer as the correct one
-
Fileland about 4 yearsThank you! I have both 1.0.2q and 1.0.2r in folder, and did the step for 1.0.2q. It works!
-
Alex about 4 yearsCan you explain a bit what
brew switch
do? I tried your solution and everything works now, but when I runopenssl version
command it still shows I am using LibreSSL 2.6.5. I am confused about how python picks up openssl 1.0.2 instead of LibreSSL in my system @Rockallite -
imsheth almost 4 yearsWorked after I used @poca 's answer and then above answer
-
Andrew Faulkner almost 4 yearsThanks so much, you're a lifesaver - this finally worked after fighting with it for over an hour.
-
Patrick almost 4 yearsYou sir, deserve a medal! Clearly laying out the steps here is really helpful. It was
1.0.2s
for me :) -
user2401543 almost 4 yearsThanks! This problem occured in my Zshell on 10.15.4. I checked openssl which is 1.0.2s on my machine and
brew switch openssl 1.0.2s
did the job. -
guozqzzu almost 4 yearsThank you vvvvvery much ! I met this error when i run
gclient sync
. The openssl on my Mac is 1.0.2s. So i runbrew switch openssl 1.0.2s
. -
Tarique Shamim almost 4 yearsI want to give a medal to this guy. Thanks a ton for the help.
-
Mahdi almost 4 yearsThird time in a few months I am saved by this! :'D
-
keshav.bahadoor almost 4 yearsUninstalling python, and then clearing the
pyenv
directory seemed to solve it for me.rm -R ~/.pyenv
-
Cheruvim almost 4 yearsSo Now with the installation of zsh and Calalina there is no
/usr/local/Cellar/openssl
what's a 2.7 junkie to do? -
ET Come Back over 3 yearsI have no idea what's going on, but this worked with 1.0.2q! Thanks!
-
Sangbeom Han over 3 yearsThanks! I got this error after the macOS update. Catalina 10.15.6
-
davidbitton over 3 yearsAny way to double up-vote this? I saw the same as @quozqzzu; 1.0.2s. Thanks!
-
Tchakabam over 3 yearsI did the same but instead step 2) I did
brew remove python@2
:) macOS Catalina ships Python 2.7 built-in and it seemed less issue prone then to rely on that directly. To me python support via brew seemed to always cause some issue somewhere in that past xD -
loretoparisi over 3 yearsIt worked for me, in my case
openssl
version was1.1.1h
, so command to fix wasbrew switch openssl 1.1.1h
-
markemus over 3 yearsI laughed but as a warning to noobs- don't do this.
-
Fixee over 3 years
brew switch
was removed github.com/Homebrew/discussions/discussions/339 -
Wayne about 3 yearsFollowing the reinstall instructions in the answer on this SO post: link , along with reinstall of [email protected] worked to get me past these hashlib errors.
-
DoneDeal0 about 3 yearsA bit late in the game, but thank you, your solution works perfectly!
-
Gianni almost 3 yearsThis worked great for me! thank you. I spent a lot of time installing things and this took just two seconds 👍
-
chadlagore almost 3 yearsIn the absence of
brew switch
, and a missing1.0.2t
locally for me, I usedbrew install [email protected]
, which installed1.0.2t
. You might need tobrew tap rbenv/tap
to get the recipe. After this I need to add openssl 1.0 to my path. For me, this wasecho 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
. -
SR. over 2 yearsWorked for me on MacOS 🤟
-
Raymond over 2 yearsIt's freaking me out, not working for me on MacOS