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:
JavaScript
x
68
68
1
hg commit --amend
2
ERROR:root:code for hash md5 was not found.
3
Traceback (most recent call last):
4
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>
5
globals()[__func_name] = __get_hash(__func_name)
6
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
7
raise ValueError('unsupported hash type ' + name)
8
ValueError: unsupported hash type md5
9
ERROR:root:code for hash sha1 was not found.
10
Traceback (most recent call last):
11
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>
12
globals()[__func_name] = __get_hash(__func_name)
13
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
14
raise ValueError('unsupported hash type ' + name)
15
ValueError: unsupported hash type sha1
16
ERROR:root:code for hash sha224 was not found.
17
Traceback (most recent call last):
18
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>
19
globals()[__func_name] = __get_hash(__func_name)
20
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
21
raise ValueError('unsupported hash type ' + name)
22
ValueError: unsupported hash type sha224
23
ERROR:root:code for hash sha256 was not found.
24
Traceback (most recent call last):
25
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>
26
globals()[__func_name] = __get_hash(__func_name)
27
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
28
raise ValueError('unsupported hash type ' + name)
29
ValueError: unsupported hash type sha256
30
ERROR:root:code for hash sha384 was not found.
31
Traceback (most recent call last):
32
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>
33
globals()[__func_name] = __get_hash(__func_name)
34
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
35
raise ValueError('unsupported hash type ' + name)
36
ValueError: unsupported hash type sha384
37
ERROR:root:code for hash sha512 was not found.
38
Traceback (most recent call last):
39
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>
40
globals()[__func_name] = __get_hash(__func_name)
41
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
42
raise ValueError('unsupported hash type ' + name)
43
ValueError: unsupported hash type sha512
44
Traceback (most recent call last):
45
File "/usr/local/bin/hg", line 43, in <module>
46
dispatch.run()
47
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 150, in __getattr__
48
self._load()
49
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 94, in _load
50
_origimport, head, globals, locals, None, level)
51
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 43, in _hgextimport
52
return importfunc(name, globals, *args, **kwargs)
53
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/dispatch.py", line 625, in <module>
54
class lazyaliasentry(object):
55
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/dispatch.py", line 636, in lazyaliasentry
56
@util.propertycache
57
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 150, in __getattr__
58
self._load()
59
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 94, in _load
60
_origimport, head, globals, locals, None, level)
61
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 43, in _hgextimport
62
return importfunc(name, globals, *args, **kwargs)
63
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/util.py", line 180, in <module>
64
'md5': hashlib.md5,
65
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 151, in __getattr__
66
return getattr(self._module, attr)
67
AttributeError: 'module' object has no attribute 'md5'
68
I also tried following the instruction on this issue but none of the solutions seem to work
JavaScript
1
12
12
1
brew link openssl --force
2
Warning: Refusing to link macOS-provided software: openssl@1.1
3
If you need to have openssl@1.1 first in your PATH run:
4
echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc
5
6
For compilers to find openssl@1.1 you may need to set:
7
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
8
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
9
10
For pkg-config to find openssl@1.1 you may need to set:
11
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
12
Advertisement
Answer
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:
JavaScript
1
2
1
$ ls /usr/local/Cellar/openssl
2
…which shows
JavaScript
1
2
1
1.0.2t
2
According to the existing version, run:
JavaScript
1
2
1
$ brew switch openssl 1.0.2t
2
…which shows
JavaScript
1
3
1
Cleaning /usr/local/Cellar/openssl/1.0.2t
2
Opt link created for /usr/local/Cellar/openssl/1.0.2t
3
After that, run the following command in a Python 2.7 virtualenv:
JavaScript
1
2
1
(my-venv) $ python -c "import hashlib;m=hashlib.md5();print(m.hexdigest())"
2
…which shows
JavaScript
1
2
1
d41d8cd98f00b204e9800998ecf8427e
2
No more errors.