使用任何hg mercurial命令时,“找不到哈希md5的ERROR:root:code”


102

尝试hg在控制台上使用任何Mercurial命令时,我一直收到此错误。我使用Homebrew安装了Python,并且正在运行Mac OS Catalina v.1.5.1。

任何参考将不胜感激。这是我得到的错误:

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'

我也尝试按照此问题上的说明进行操作,但所有解决方案似乎均不起作用

brew link openssl --force
Warning: Refusing to link macOS-provided software: openssl@1.1
If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

1
您到问题1的链接丢失。
UuDdLrLrSs


MacOS的任何解决方案?我确实尝试过这些解决方案,但都没有用。我不断收到相同的错误。当我尝试链接到我粘贴在问题中的openssl时,我收到了粘贴在那里的错误。我也尝试运行这4条命令,但没有任何反应:echo'export PATH =“ / usr/local/opt/openssl@1.1/bin:$ PATH”'>>〜/ .zshrc export LDFLAGS =“-L / usr / local /opt/openssl@1.1/lib“导出CPPFLAGS =”-I/usr/local/opt/openssl@1.1/include“导出PKG_CONFIG_PATH =” / usr/local/opt/openssl@1.1/lib/pkgconfig“
poca

Answers:


320

brew reinstall python@2对于我现有的Python 2.7虚拟环境,运行不起作用。在他们里面仍然有ERROR:root:code for hash sha1 was not found错误。

我跑步后遇到了这个问题brew upgrade openssl。解决方法是:

$ ls /usr/local/Cellar/openssl

...这表明

1.0.2t

根据现有版本,运行:

$ brew switch openssl 1.0.2t

...这表明

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

之后,在Python 2.7 virtualenv中运行以下命令:

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

...这表明

d41d8cd98f00b204e9800998ecf8427e

没有更多的错误。


10
这帮助我进行了Mac Catalina更新或bash-> zsh,其中大量此类事情被破坏了。
NathanQ

3
我没有1.0.2q但这样做与1.0.2r同样也工作了
马特·科迪

2
是。这对我有用。我在此上花了几天的时间,并且担心不得不重新映像我的机器。我试图多次重新安装python @ 2,但仍然无法解决问题。这绝对有效。MacOS Mojave 10.14.6。
hb5fa

1
是的,它有效。花了几天的时间尝试千种解决方案
ariezona

1
@FlorentRoques,因为您将拥有与示例相同的版本。在我的情况下ls /usr/local/Cellar/openssl返回1.0.2s,所以我需要运行brew switch openssl 1.0.2s
Jaybeecave

86

通过首先取消链接openssl来解决此问题

brew unlink openssl

然后重新安装python

brew reinstall python@2

我还注意到,在运行“ brew doctor”时,在/ usr / local / include / node /中有一个与openssl文件夹有关的警告。我在运行上述命令之前删除了此文件夹(不确定是否相关)


2
我没有链接的openssl,但是重新安装python为我做了。谢谢!
chrysillo

救生员-谢谢。我在安装Google Cloud SDK时遇到了类似的问题,这解决了该问题。
jonhendrix

我不得不重新连接了蔚蓝啤酒与啤酒
chaosguru

自2020年2月10日起,python @ 2已从自制软件中删除,此答案将无效。请参阅@Rockallite提供的上述答案,该答案对我来说非常理想。
保罗

感谢@Paul的更新,我将上面的答案标记为正确的答案
poca

30

对我来说,当我安装django网络应用程序的依赖项时,会弄乱环境。当我打字cd,它显示相同的错误。

问题是openssl图书馆,找不到正确的图书馆。

如果您使用的是Macintosh,则可以输入

ls /usr/local/Cellar/openssl

查看所有版本,

brew switch openssl 1.0.XXXX

选择可用的openssl版本。

然后错误消失了:)


4
一支班轮bash ls /usr/local/Cellar/openssl | xargs brew switch openssl
Florent Roques

工作,我用@poca的回答后,然后上面的回答
imsheth

0

当我导入hashlib时,会看到一条错误消息,指出未找到哈希md5。

我能够通过首先取消链接openssl来解决此问题:brew unlink openssl

然后,我使用MacPorts卸载了python 2.7:sudo port卸载python27

然后我使用MacPorts安装了python 2.7:sudo port install python27

现在导入hashlib可以工作了:)


0

只需卸载python2

$ brew uninstall python@2

如果有任何错误:

$ brew uninstall --ignore-dependencies python@2

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.